Bungled Inheritence: Layered Constructors
I'm *positive* someone has asked this before...but I couldn't find it in the search, sorry, so I'm asking again.
I have a base class called Object, with the following constructor:
Object.cpp:
Code:
Object::Object()
{
burnable = false;
edible = false;
equipable = false;
wearable = false;
keyID = -1; // not a key
lockID = -1; // not a lock
name = "New Object.";
floorDescription = "A dusty new object lies on the floor.";
}
All those variables that are modified there are PRIVATE Object variables.
Now, I have a class Container, which is an extention of Object. I do the following:
Container.h:
Code:
class Container : public Object
Container.cpp:
Code:
Container::Container()
{
Container::Object();
floorDescription = "You spy a new container lies here.";
name = "New Container";
isOpen = false;
}
This is to avoid resetting all the params to default values again in the Container constrcturo. This works fine, except when I try to modify floorDescription and name (private fields in Object class), I get the following errors:
std::string Object::floorDescription' is private Object.h
std::string Object::name' is private Object.h
Any ideas?