class Connection
{
public:
typedef boost::shared_ptr pointer;
static pointer create(boost::asio::io_service& io_service){return pointer(new Con
You have decided to make Connection
abstract, but then attempted to instantiate it. Which did you mean to do?
You have not provided a definition for OnReceived
, it is therefore a pure virtual (abstract) method and the class an abstract class. You cannot instantiate an object of an abstract class. To use the method OnReceived
you have to, well, provide an implementation for it (what does it do at the moment? nothing). Abstract classes are intended to be subclassed by concrete implementations which then provide implementations for the pure virtual methods.
EDIT: The part new Connection(io_service)
does not work for the above mentioned reason: you cannot create an object of a class, that has pure virtual functions (those declarations ending with = 0;
). You need to subclass Connection
and provide implementations for those methods (like OnConnected
). Your old class didn't have that problem. It had pure virtual methods, but you have not tried to instantiate it. If you still don't see the error, I suggest you to consult some material on object-orientation in C++, especially virtual and pure virtual methods.
You an use it, but not until it is implemented in some derived class.
You cannot create objects of abstract classes, because not all functions are implemented.