Okay.
Say I have a base class which has some physics objects in its private members so;
NOTE - THIS IS A MINIMAL EXAMPLE.
BaseObject Header:
class BaseObject
{
BaseObject();
~BaseObject();
b2Body& GetBody();
b2BodyDef& GetBodyDef();
b2FixtureDef& GetFixtureDef();
b2PolygonShape& GetPolygon();
b2World& GetWorld();
private:
b2Body* mBody;
b2BodyDef mBodyDef;
b2FixtureDef mFixtureDef;
b2PolygonShape mPolygon;
b2World *mWorld;
};
and I have a class that inherits it so;
DerivedObject Header:
class DerivedObject: public BaseObject
{
public:
DerivedObject(void);
~DerivedObject(void);
private:
};
DerivedObject code:
DerivedObject ::DerivedObject ()
: BaseObject()
{
this->GetBody() = this->GetWorld().CreateBody(this->GetBodyDef());
}
Now, as with Box2d, it requires lots of initiating the variables. C++ does not allow me to use them as I use above, it gives errors like 'no operator matches =' and 'const this' errors, but I don't know how else to do it? I don't want to make them all public in the BaseClass.. is there any syntax to get around this?
I have use Protected, and that works perfectly and is not accessible to the outside world, but is there any syntax to be able to use the above logic with private get/setters?