V
vjedlicka
Hi all,
Can you please tell me what is wrong with this? I do not know how to
iterate
thru a vector. The error is shown on the last line.
Thank you
Vaclav
typedef boost::shared_ptr<MySillyClass> mySharedPtr;
std::vector<mySharedPtr> vec;
vec.push_back( mySharedPtr(new MySillyClass("bigString")) );
vec.push_back( mySharedPtr(new MySillyClass("smallOne")) );
vec.push_back( mySharedPtr(new MySillyClass("anotherOne")) );
vec.push_back( mySharedPtr(new MySillyClass("bullShit")) );
mySharedPtr ptr2 = vec[2];
if(ptr2.use_count() > 0)
{
ptr2->DoSomething(); // <------- works OK
}
for (std::vector<mySharedPtr>::iterator i = vec.begin(); i !=
vec.end();
++i)
{
i->DoSomething(); // <------- gives error "DoSomething' : is
not a
member of 'shared_ptr<class MySillyClass>"
}
Can you please tell me what is wrong with this? I do not know how to
iterate
thru a vector. The error is shown on the last line.
Thank you
Vaclav
typedef boost::shared_ptr<MySillyClass> mySharedPtr;
std::vector<mySharedPtr> vec;
vec.push_back( mySharedPtr(new MySillyClass("bigString")) );
vec.push_back( mySharedPtr(new MySillyClass("smallOne")) );
vec.push_back( mySharedPtr(new MySillyClass("anotherOne")) );
vec.push_back( mySharedPtr(new MySillyClass("bullShit")) );
mySharedPtr ptr2 = vec[2];
if(ptr2.use_count() > 0)
{
ptr2->DoSomething(); // <------- works OK
}
for (std::vector<mySharedPtr>::iterator i = vec.begin(); i !=
vec.end();
++i)
{
i->DoSomething(); // <------- gives error "DoSomething' : is
not a
member of 'shared_ptr<class MySillyClass>"
}