#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<<
;} }; 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(); } }
#include
#include
#include
#include
class A { public: A(std::string s){a=s;} std::string a; void print(){std::cout<
p1(new A("2345")); boost::shared_ptr
p2(new A("dfgds")); std::vector< boost::shared_ptr
> m; std::vector< boost::shared_ptr
>::iterator it; m.push_back(p1); m.push_back(p2); for (it=m.begin();it!=m.end();it++) { (*it)->print(); } }
#include
#include
#include
#include
class A { public: A(std::string s){a=s;} std::string a; void print(){std::cout<
p1(new A("2345")); boost::shared_ptr
p2(new A("dfgds")); std::vector< boost::shared_ptr
> m; std::vector< boost::shared_ptr
>::iterator it; m.push_back(p1); m.push_back(p2); for (it=m.begin();it!=m.end();it++) { (*it)->print(); } }