In the code below, I have declared string name
in class SHAPE
so that the sub-classes can have a constant name.
But, the g++ compiler gives the error inside CIRCLE
class that 'name' does not name a type
.
class SHAPE
{
protected:
string name;
};
class CIRCLE : public SHAPE
{
name = "circle";
public:
void display()
{
cout<<name;
}
};
I am new to OOP and C++. Any help in correcting and improving my code will be appreciated.