[osg-users] Copy constructor and assignment operator

Yip Leng Wong yiplengwong at rocketmail.com
Tue Sep 9 01:32:05 PDT 2008

As I'm a new user of OpenSceneGraph, pardon me for this simple question:
For the following class:
class Foo
    Foo() {}
   virtual ~Foo() {}
    osg::ref_ptr<osg::Node> mNode;
since mNode is a pointer, is it a must to provide a copy constructor and assignment operator for deep copy to prevent dangling pointer?
If there is a need to provide the copy constructor and assignment operator, is it correct as illustrated by the codes below?
Foo(const Foo& other)
    mNode = other.mNode;
Foo& operator=(const Foo& other)
    if (this == &other)
        return *this;
   mNode = new osg::Node;
    mNode = other.mNode;
    return *this;
Yip Leng

      New Email names for you! 
Get the Email name you've always wanted on the new @ymail and @rocketmail.. 
Hurry before someone else does!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080909/2da3abae/attachment-0002.htm>

More information about the osg-users mailing list