|
Boost Users : |
From: Vaclav (vjedlicka_at_[hidden])
Date: 2007-03-05 11:28:13
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>"
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net