我正在构建一个服务类,我希望将ioService存储为类成员。这是代码:
SocketServer.hpp
class SocketServer {
public:
SocketServer(boost::asio::io_service& service);
virtual ~SocketServer();
private:
boost::asio::io_service &ioService;
}
SocketServer.cpp
SocketServer::SocketServer(boost::asio::io_service &service) :
ioService(service) {}
SocketServer::~SocketServer() {};
编译时,我在构造函数实现中遇到以下错误:
error: no matching function for call to ‘boost::asio::basic_socket_acceptor<boost::asio::ip::tcp>::basic_socket_acceptor()’
我知道ioService
是不可复制的,但我试图存储它的引用,而不是复制对象本身。
这里发生了什么?我该如何解决?