*/ this is the Cat header file/*
#include <iostream>
class Cat
{
public:
cat(int initial age);
~cat();
int GetAge() const {return itsAge;} //inline function
void SetAge (int age) {itsAge=age;} //inline function
void meow() const {stc::cout<<"Meow.\n";} //inline function
private:
int itsAge;
};
*/ this is the cat.cpp file /*
#include "cat.hpp"
#define cout std::cout
Cat::Cat(int initialAge)//constructor
{
itsAge= initialAge;
}
Cat::~Cat() //destructor
{
}
int main()
{
cat frisky(5);
frisky.meow();
cout<<"frisky is a cat who is "<<GetAge()<<" years old!\n";
frisky.meow();
frisky.SetAge(7);
cout<<"frisky is now "<<GetAge()<<" years old!\n";
frisky.meow();
return 0;
}
No comments:
Post a Comment