I am learning C++. And I really can't understand why I can't age like this (in cat class. Can anyone help me?
class Animal{
public :
void speak();
int getAge(){
return age;
}
protected :
int age;
};
class Cat : public Animal{
public :
Cat(int age = 0) : age{age}{
}
void eat(){
std::cout << "I eat mouse." << std::endl;
}
void speak(){
std::cout << "Miaow" << std::endl;
}
};