#include <iostream>
#include <vector>
#include <string>
#include <boost/shared_ptr.hpp>
class A
{
public:
A(std::string s){a=s;}
std::string a;
void print(){std::cout<<a<<'\n';}
};
void main()
{
boost::shared_ptr<A> p1(new A("2345"));
boost::shared_ptr<A> p2(new A("dfgds"));
std::vector< boost::shared_ptr<A> > m;
std::vector< boost::shared_ptr<A> >::iterator it;
m.push_back(p1);
m.push_back(p2);
for (it=m.begin();it!=m.end();it++)
{
(*it)->print();
}
}
转载于:https://www.cnblogs.com/tiandsp/archive/2012/02/07/2341775.html