C++ Iterating through a vector of smart pointers

a 夏天 提交于 2019-12-03 06:22:12

Don't you mean

(*i)->RenderShape(destination); 

?

i is the iterator, *i is the shared_ptr, (*i)::operator->() is the object.

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); 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!