[osg-users] how to ref_ptr -> operator work?

Somerville, Andrew asomerville at foster-miller.com
Thu Jul 3 20:01:12 PDT 2008


the fact that the "->" operator dereferences the value it returns is a quirky rule of C++. "->" behaves a bit like a unary operator but not completely. "a->setName()" would resolve to something nonsensical if "(a->)" simply resolved to its return type.

so it is a C++ issue.

a->setName() as you have seen is the correct way to call functions on the ref_ptr.


    Andy


-----Original Message-----
From: osg-users-bounces at lists.openscenegraph.org on behalf of ? ?
Sent: Thu 7/3/2008 10:18 PM
To: osg-users at lists.openscenegraph.org
Subject: [osg-users] how to ref_ptr -> operator  work?
 
 osg::ref_ptr<osg::Node>  a = new osg:Node;
   a->setName(); //OK
   
  but ref_ptr overload -> operator and  return  a pointer to osg:Node,
  so may  write (a->)->setName()  is right? WHY?
   
  Thanks !
  
   

       
---------------------------------
 ????,??????!




More information about the osg-users mailing list