Advertisement

Help me! - Classes, pointers and arrays

Started by May 24, 2000 03:15 AM
11 comments, last by nramsbottom 24 years, 6 months ago
Just a small correction so nramsbottom doesn''t get confused when looking at this wonderfull dog class =) and wondering where m_nAge came from. You forgot to declare the member variable m_nAge, so the class should read:

class Dog
{
public:
Dog(int age = 0){m_nAge = age;}
int GetAge(void){return m_nAge;}
void SetAge(int age){m_nAge = age;}
void Bark(void){cout << "Ruff ruff.\n";}

private:
m_nAge; // Made this private since you provided accesor
};

I think that the entire text of Sams Teach Yourself C++ in 21 Days, Second Edition is available online at informit.com and I just found out that the free book at about.com is Sams Teach Yourself C++ in 21 Days, Third Edition.

-TMOLI 42
- TMOLI 42 Powered by hypocrisy!"Go crazy? Don't mind if I do!" - Homer Simpson
Advertisement

Ruff, Ruff


hehe

"I live to give"

This topic is closed to new replies.

Advertisement