unexpected class error
Apr 20, 2012 at 5:25pm UTC
well this is word for word one of the examples from my c++ book, I have no idea what the error means, the error is: error: new types may not be defined in a return type. it occurs on line 3
here is code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#include <iostream>
class Cat //error occurs here
{
public :
Cat(int initialAge);
~Cat();
int getAge();
void setAge(int age);
void meow();
private :
int cAge;
}
Cat::Cat(int initialAge)
{
cAge = initialAge;
}
Cat::~Cat() {}
int Cat::getAge()
{
return cAge;
}
void Cat::setAge(int age)
{
cAge = age;
}
void Cat::meow()
{
std::cout<<"Meow.\n" ;
}
int main()
{
using namespace std;
Cat frisky(5);
frisky.meow();
cout<<"Frisky is a cat who is " <<frisky.getAge()<<" years old.\n" ;
frisky.meow();
return 0;
}
Apr 20, 2012 at 5:29pm UTC
Missing semicolon line 13.
Apr 20, 2012 at 5:42pm UTC
thank you, didnt notice that...
Topic archived. No new replies allowed.