answersLogoWhite

0

Accessors (getters) and mutators (setters) are defined as you would define any member function, usually using the attribute's name prefixed with get_ or set_ as appropriate. Accessors are typically defined as constant member functions that return values (copies of attributes), but you can also return references and pointers to the actual attributes if required, even though these can both undermine encapsulation. However, returning constant references or contant pointers to constant types ensures encapsulation is maintained without creating any unecessary copies of an object (the caller can make a volatile copy when desired). Mutators typically accept a constant value, reference or pointer and act as a data validator, verifying that the incoming data is acceptable before physically setting the member. The return value of a mutator is often void, but when validation is not a concern, it can be useful to return the current value (prior to mutation), thus allowing the caller to easily determine if the object has been mutated or not.

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

Can you declare a method within a method in c or c plus plus?

C: there are no methods in C. C++: no.


What is a method in c plus plus?

In C++, methods are simply class member functions.


What do you call an object function in c plus plus?

method


What is definition of employee code in c plus plus?

la la land


What is the difference between declaration and a definition in c plus plus?

A declaration is an incomplete type whereas a definition is a complete type.


How the end of file can be detected in c plus plus?

Use the istream::eof() method.


Where can you find quine mccluskey method written in C plus plus?

See related link. It's in C rather than C++, but conversion to C++ is fairly simple.


Is overriding a dynamic polymorphism in c plus plus or not?

In C++, overriding and function, method, or operator is a different thing than (dynamic) polymorphism, so overriding a polymorphic method is almost entirely possible.


What is the technical definition of architecture?

a squared plus b squared is c squared


Definition of Looping in c and c plus plus?

Looping means you repeat a particular procedure a specified number of times or until a defined condition is met.


When matching each problem (term) with its sum or difference (definition). Match Term Definition 4.23 plus 16.21 A) 26.09 42.3 plus 1.621 B) 43.921 4.23 and minus 1.621 C) 20.44 42.3 and minus 16.21 D?

The term "4.23 plus 16.21" matches with definition A) 26.09. The term "42.3 plus 1.621" matches with definition B) 43.921. The term "4.23 and minus 1.621" matches with definition C) 20.44. The term "42.3 and minus 16.21" matches with definition D.


How is hiding method different from overriding method in c sharp?

Hiding means a class cannot see the definition. Overriding implies that a class must see that to "override"