Hi everyone, I've been reading the recommended text (online version, rev2) and have been stumped on some code.
While google-ing to find the answer I stumbled across this workshop and thought it would be the ideal place to get assistance (and provide assistance) while learning this complex language.
Although I'm reading rev2 of the text, I hope my question is still relevant...
In listing 6.3 - Implementing the methods of a simple class, there is a strange call I can't get my head around.
(I wont post the whole code to save space, but if it's required I'm more than happy to do so)
6: class Cat // begin declaration of the class7: {8: public: // begin public section9: int GetAge(); // accessor function10: void SetAge (int age); // accessor function11: void Meow(); // general function12: private: // begin private section13: int itsAge; // member variable14: };15:16: // GetAge, Public accessor function17: // returns value of itsAge member18: int Cat::GetAge()19: {20: return itsAge;21: }
How is it possible to return "itsAge" on line 20 when no information has been passed to the function? I thought that when working with functions you needed to pass anything required in between the ()'s (like "int age" on line 10).
I guess my question, how does "int Cat::GetAge()" get information from the class declaration (int itsAge) without saying "int Cat::GetAge(int itsAge)"?
Any help clarifying this would be greatly appreciated.
- Scattered