View Single Post
Old 08-17-2002, 01:53 AM   #1 (permalink)
w00t
Totally Inept
 
w00t's Avatar
 
Join Date: Jul 2002
Location: The Great Northwest
Posts: 195
w00t is on a distinguished road
Exclamation Please....Help...M..E....

Find the bug in this code :

// Demonstrates declaration of constructors and
// destructor for the Cat class

#include <iostream.h>

class Cat // Declaration of the class Cat
{
public:
int GetAge; // accessor function
void SetAge (int Age); // accessor function
void Meow(); // general function
private: // begin private section
int itsAge; // member variable
};

// GetAge, Public accessor function
// Returns value of itsAge member
int Cat::GetAge()
{
return itsAge;
}

// definition of SetAge, public
// accessor function
// returns sets itsAge member
void Cat::SetAge(int Age)
{
// set member variable itsAge to
// value passed in by parameter age
itsAge = Age;
}

// definition of Meow method
// returns: void
// parameters: none
// actions: prints "meow" to screen
void Cat::Meow()
{
cout << "Meow.\n";
}

//create a Cat, set its age, have it
// meow, tell us it's age, then meow again.
int main()
{
Cat Frisky;
Frisky.SetAge (5);
Frisky.Meow();
cout << "Frisky is a cat who is \n ";
cout << Frisky.GetAge() << " Years old.\n";
Frisky.Meow();
return 0;
};
Errors:
Inoname00.cpp(19,2):'Cat::getAge()' is not a member of 'Cat'
Error: Frisky2.cpp(50,26):Call of nonfunction

I've spent a good long time looking for this and if someone could help me, I'd be eternally grateful:rock:

Thanks,
--Cj
__________________
Office Space:
Best Movie.
Ever.

Contrary to popular belief, the true function of a programmer
is to turn coffee into source code.
w00t is offline   Reply With Quote