c++ accessor methods?
what is the use of accessor methods in c++?i mean what is there importantance?
and i have another question about them,plzz see this source code:
if my class declaration was this:
5: class Cat
6: {
7: public:
8: // public accessors
9: unsigned int GetAge();
10: void SetAge(unsigned int Age);
11:
12: unsigned int GetWeight();
13: void SetWeight(unsigned int Weight);
14:
15: // public member functions
16: Meow();
17:
18: // private member data
19: private:
20: unsigned int itsAge;
21: unsigned int itsWeight;
22:
23: };
Cat Frisky;
Frisky.SetAge(5);
and i try to pass the 5 value to my accessor setage then how do the public accessor chooses the
private variable itsAge to store the 5 value,i mean why don't the public accessor setAge passes
the value 5 to the private variable itsWeight?
Regards;
Ghost Of Death