class Connection
{
public:
  typedef boost::shared_ptr<Connection> pointer;
  static pointer create(boost::asio::io_service& io_service){return pointer(new Connection(io_service));}

  explicit Connection(boost::asio::io_service& io_service);
  virtual ~Connection();
  boost::asio::ip::tcp::socket& socket();
  
  -->>>virtual void OnConnected()=0;
  void Send(uint8_t* buffer, int length);
  bool Receive();
private:
  void handler(const boost::system::error_code& error, std::size_t bytes_transferred );
  boost::asio::ip::tcp::socket socket_;
};

when am trying to use virtual void OnConnected()=0; it gives me this stupid error idk whats wrong!!!

1	IntelliSense: object of abstract class type "Connection" is not allowed:	d:\c++\ugs\accountserver\connection.h	17

whats wrong and how can i fix it while in my old connection class it was working good!!

class Connection
{
    public:
        explicit Connection(int socket);
        virtual ~Connection();

		virtual void OnConnected() =0;
        virtual int Send(uint8_t* buffer, int length);
        bool Receive();
        int getSocket() const;
		void Disconnect();
    protected:
		virtual void OnReceived(uint8_t* buffer, int len) = 0;
    private:
        int m_socket;
		bool disconnecting;
};

so what am missing here!!

The error message says it all. You have made the function OnConnected() a pure virtual function which means that it has no implementation in the class Connection, which, in turn, forces you to provide a class, derived from Connection, that implements this function. In short, this pure virtual function makes the Connection class an "Abstract Class" and an object of that class cannot be created. You need to create a derived class, with an implementation for OnConnected(), and create an object of that class instead. In other words, you need to revise your implementation of your factory function create() which creates an object of Abstract class Connection. The second version succeeds only because you don't have that erroneous factory function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.