title: cannot access private member declared in class 'boost::asio::basic_io_object<IoObjectService>
body: <p><code>boost::asio::basic_io_object&lt;IoObjectService&gt;::basic_io_object' : cannot access private member declared in class 'boost::asio::basic_io_object&lt;IoObjectService&gt;</code></p>
  
  <p>it does not tell where is this error is occurring :|, here is my codes</p>
  
  <p>AsyncConnection</p>
  
  <pre><code>#ifndef _ASYNCCONNECTION_H_
  #define _ASYNCCONNECTION_H_
  
  #include &lt;boost\shared_ptr.hpp&gt;
  #include &lt;boost\enable_shared_from_this.hpp&gt;
  #include &lt;boost\bind.hpp&gt;
  #include &lt;boost\asio.hpp&gt;
  
  class AsyncConnection : public boost::enable_shared_from_this&lt;AsyncConnection&gt;
  {
  public:
      typedef boost::shared_ptr&lt;AsyncConnection&gt; Pointer;
      explicit AsyncConnection(boost::asio::ip::tcp::socket&amp; socket);
      virtual ~AsyncConnection();
  
      virtual void BeginReceive();
      virtual void EndReceive(const boost::system::error_code&amp; error, std::size_t bytes_transferred);
  
      boost::asio::ip::tcp::socket&amp; GetSocket();
  private:
      boost::asio::ip::tcp::socket m_socket;
      char buffer[1024];
  };
  
  #endif
  
  
  #include "AsyncConnection.h"
  
  
  AsyncConnection::AsyncConnection(boost::asio::ip::tcp::socket&amp; socket)
      : m_socket(socket)
  {
  }
  
  
  AsyncConnection::~AsyncConnection()
  {
  }
  
  
  boost::asio::ip::tcp::socket&amp; AsyncConnection::GetSocket(){
      return m_socket;
  }
  
  void AsyncConnection::BeginReceive(){
  
      boost::asio::async_read(socket, boost::asio::buffer(buffer),
          boost::asio::transfer_at_least(1),
          boost::bind(&amp;AsyncConnection::EndReceive, shared_from_this(),
          boost::asio::placeholders::error,
          boost::asio::placeholders::bytes_transferred));
  }
  
  void AsyncConnection::EndReceive(const boost::system::error_code&amp; error, std::size_t bytes_transferred){
      if (!error){
  
      }
      else{
          std::cout &lt;&lt; error.message() &lt;&lt; std::endl;
      }
  }
  </code></pre>
  
  <p>IAsyncConnectionFactory</p>
  
  <pre><code>#ifndef _IASYNCCONNECTIONFACTORY_H_
  #define _IASYNCCONNECTIONFACTORY_H_
  
  #include "AsyncConnection.h"
  
  class IAsyncConnectionFactory
  {
  public:
      IAsyncConnectionFactory();
      virtual ~IAsyncConnectionFactory();
  
      virtual AsyncConnection::Pointer Create(boost::asio::ip::tcp::socket&amp; socket) = 0;
  };
  
  #endif
  </code></pre>
  
  <p>AsyncServer</p>
  
  <pre><code>#pragma once
  #ifndef _ASYNCSERVER_H_
  #define _ASYNCSERVER_H_
  
  #include &lt;string&gt;
  #include &lt;boost/bind.hpp&gt;
  #include "IAsyncConnectionFactory.h"
  
  using boost::asio::ip::tcp;
  
  class AsyncServer
  {
  public:
      AsyncServer(boost::asio::io_service&amp; io_service, std::string ip, unsigned short port, boost::shared_ptr &lt; IAsyncConnectionFactory&gt; factory);
      ~AsyncServer();
  
      void BeginAccept();
      void EndAccept(AsyncConnection::Pointer connection, const boost::system::error_code&amp; error);
  private:
      boost::shared_ptr &lt; IAsyncConnectionFactory&gt; m_factory;
      tcp::acceptor acceptor;
  };
  
  #endif
  
  #include "AsyncServer.h"
  
  
  AsyncServer::AsyncServer(boost::asio::io_service&amp; io_service, std::string ip, unsigned short port, boost::shared_ptr&lt; IAsyncConnectionFactory&gt; factory)
      : acceptor(io_service, tcp::endpoint(boost::asio::ip::address_v4::from_string(ip), port)), m_factory(factory)
  {
  
      BeginAccept();
  }
  
  
  AsyncServer::~AsyncServer()
  {
  
  }
  
  
  void AsyncServer::BeginAccept(){
      AsyncConnection::Pointer new_connection = m_factory-&gt;Create(boost::asio::ip::tcp::socket(acceptor.get_io_service()));
  
      acceptor.async_accept(new_connection-&gt;GetSocket(),
          boost::bind(&amp;AsyncServer::EndAccept, this, new_connection, boost::asio::placeholders::error));
  }
  
  void AsyncServer::EndAccept(AsyncConnection::Pointer connection, const boost::system::error_code&amp; error){
      if (!error)
      {
          connection-&gt;BeginReceive();
      }
      else
      {
          std::cout &lt;&lt; error.message() &lt;&lt; std::endl;
      }
  
      BeginAccept();
  }
  </code></pre>