Here is my code (I use boost::shared_ptr):
Code:class socket { public: SOCKET s; //all socket functions// }; typedef boost::shared_ptr<socket> socket_ptr; class client1 : public socket { public: short c; //client1 functions// }; typedef boost::shared_ptr<client1> client1_ptr; class client2 : public socket { public: short c; //client2 functions// }; typedef boost::shared_ptr<client2> client2_ptr; /// THE PROBLEM /// template <class T> //not sure if I should use template class multisock { public: list <T> sockets; };
The problem is I want to have let say 10 instances of client1/client2/or socket class and want to be able to access their members from multisock class:
this would be like that:
list <client1_ptr> sockets;
list <client2_ptr> sockets;
list <socket_ptr> sockets;
Im not sure what would be the right way to do this, probably with templates? Anyway I get errors with my code..
This is how I would do things (and get errors) for class client1:
Code:multisock mc <client1_ptr> (); for (int i = 0; i < 10; i++) { mc.sockets.push_back <client1_ptr> ( client1_ptr(new client1()) ); }



LinkBack URL
About LinkBacks


