thanks man, didn't think of doing that at the time seams like there is is bug in my code somewhere.
if i do this it will not work.
InstanceObject::InstanceObject( const BasicObject& Other )
{
dbInstanceObject ( O->Ref(), Other.O->Ref() );
}
but if i do this it will.
InstanceObject::InstanceObject( const BasicObject& Other )
{
dbInstanceObject ( O->Ref()+1, Other.O->Ref() );
}
for that i will find out whats going on. but do you know how to have a class that inherts from another access private varibles.
this is my BasicObject class witch InstanceObject inherits from.
i would like to keep ObjectRef private but i am not sure how i can do that and still have InstanceObject work by passing the object to it.
do you have any ideas how to. or is it not possible.
class BasicObject
{
public:
BasicObject();
// Destructor - virtual, because I expect this class to be inherited from
virtual ~BasicObject();
// Basic manipulators
void SetTexture(const Image& NewImage);
void Position(float x, float y, float z);
void Rotate(float x, float y, float z);
void Hide();
void Show();
void SetGhost(int iEffect);
// used for animation.
void Play();
void Speed(int iSpeed);
void SetFrame(int iFrame);
int ObjNumber(); // used for debuging not really needed
float PositionX();
float PositionY();
float PositionZ();
protected:
class ObjectRef
{
public:
ObjectRef() : ObjectNumber(FreeList.NewItem()) { }
~ObjectRef()
{
if (dbObjectExist( ObjectNumber ))
{
dbDeleteObject( ObjectNumber );
}
FreeList.ReleaseItem(ObjectNumber);
}
int Ref() const { return ObjectNumber; }
private:
int ObjectNumber;
static NumberResource FreeList;
};
public:
boost::shared_ptr<ObjectRef> O;
boost::shared_ptr<Image::ImageRef> I;
};