There are three main type of methods in C++ I read somewhere but I forgot where exactly and in which article did I read that. But it is something like Access methods, Modify methods and the third one.. I think it is managerial method. But not really sure. Can any one tell me what are those three methods with some explanation about it. If not, please do provide me a link from where I can learn more about them. I wish i could have bookmarked that article when I read that. I now really cant find any other place on the WWW which talks about these. Please help guys. :-|

Votes + Comments
methods in c++
9 Years
Discussion Span
Last Post by ~s.o.s~

Well, let me try to help if I can.

First of all consider a class like this:

class myClass {
   int data;
    myClass() {};
    ~myClass() {};
    int getData() {return data;}
    void setData(int newData) {data=newData;}
    void calculateRoot(int amount) {data=sqrt(amount);}

An accessor method is used when another method needs the value contained in a private data member of the class. An example of this would be myClass::getData() , because all it does is return the value of the data . This type of function is useful for making a read-only variable.

Modify methods would be a method that modifies a private data member inside a class. An example of this would be myClass::setData() , because it changes the value of data . Now, you may be wondering why you would use a public member function to modify a private member. Why not just make the data member public?

Well, the whole goal of object-oriented programming is to make classes relatively independant objects. In other words, if you suddenly want data to equal the value+1, the only things you should have to change is within the class itself. By changing the setter method, the whole thing is changed. If you had manually set the values from other classes, you would suddenly find yourself facing a whole ton of coding. Another good example of this is if you need to change data types in a class.

Finally... managerial functions. I've never heard such a description of them before, so I'm only guessing. I suppose it's a function that manages an object, such as constructors/destructors (memory management), or something such as a function that does more than simply modify a value in an object.

For more information on these topics, I suggest you visit the following sites:


The "modify methods" or "setter methods" are more popularly or formally known as "Mutator functions".

I agree with Joey in that the third category is not a formal one. I can make a pretty guess that the methods which are neither Accessors nor Mutators fall under the category of so called Managerial functions. For eg. the functions which perform the task of setting the parameters for the environment in which it is invoked.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.