#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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)