C++ Iterating through a vector of smart pointers

前端 未结 2 1161
别那么骄傲
别那么骄傲 2021-02-08 07:50

i have a class that has this function:

typedef boost::shared_ptr sp_PrimShapeBase; 



class Control{
     public:
         //other function         


        
2条回答
  •  旧巷少年郎
    2021-02-08 08:13

    That's because i is an iterator. Dereferencing it once gives you the smart pointer, you need to double dereference it.

    (**i).RenderShape(destination);
    

    or

    (*i)->RenderShape(destination); 
    

提交回复
热议问题