grab and drop

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
utunnels
Posts: 37
Joined: Thu Apr 05, 2012 2:52 pm

grab and drop

Post by utunnels »

I have a class with a member which points to a custom scene node class, like:

Code: Select all

class A
{
    ISceneNode* node;
};
Do I have to create a copy constructor and a destructor for that?

Code: Select all

A::A(const A& a)
{
    //copy code
    if(node) node->grab();
}
 
A::~A()
{
    if(node) node->drop();
}
 
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: grab and drop

Post by REDDemon »

Code: Select all

 
class A
{
    ISceneNode * MyNode;
public:
 
    void setNode(ISceneNode* node)
    {
        node->grab();
        MyNode->drop();
        MyNode = node;
    }
 
    A(ISceneNode *node)
    {
        (MyNode=node)->grab();
    }
 
    ~A() //destructor
    {
        MyNode->drop();
    }
}
 
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
utunnels
Posts: 37
Joined: Thu Apr 05, 2012 2:52 pm

Re: grab and drop

Post by utunnels »

Thank you. It makes sense to me now.
Post Reply