- #1
walnutTree
- 5
- 0
Dear All,
I have got a subclass (Panda), which inherits a Print function from the base class (Bear).
I'd like to be able to call the base class's function from the subclass.
But my complier gives me the following error message:
In member function `virtual void Panda::print(char)':
expected primary-expression before "char"
I use DEV-CPP.
Heres is my code causing the problem:
Could you tell me what's the wrong?
Any ideas would be appreciated!
I have got a subclass (Panda), which inherits a Print function from the base class (Bear).
I'd like to be able to call the base class's function from the subclass.
But my complier gives me the following error message:
In member function `virtual void Panda::print(char)':
expected primary-expression before "char"
I use DEV-CPP.
Heres is my code causing the problem:
Code:
class Bear{
public:
virtual void print(char x)
{
std::cout<<"bear"<<std::endl;
}
};
class Panda : public Bear{
public:
void print(char x)
{
Bear::print(char x);
std::cout<<"panda"<<std::endl;
}
};
Could you tell me what's the wrong?
Any ideas would be appreciated!