Reputation: 1626
I have a simple Class with boost socket as member, and I'm trying to pass IP address to it's constructor, which gives me the compile error.
Error 2 error C2248: 'boost::asio::basic_io_object<IoObjectService>::basic_io_object' : cannot access private member declared in class 'boost::asio::basic_io_object<IoObjectService>'
However if i remove the std::string ip argument from it's constructor it's works fine. Any idea why It's not compiling
class TestConnection
{
private:
boost::asio::ip::tcp::socket tcp_socket_;
public:
TestConnection(boost::asio::io_service &io, std::string ip):tcp_socket_(io)
{
}
~TestConnection()
{
}
};
int main()
{
boost::asio::io_service io_service;
std::string test_ip = "192.168.1.10";
TestConnection testconn = TestConnection(io_service, test_ip);
}
Upvotes: 0
Views: 1348
Reputation: 15075
TestConnection testconn = TestConnection(io_service, test_ip);
In the above line you actually attempt to invoke TestConnection
copy-constructor, which is unavailable, because tcp_socket_
member is non-copyable. Instead, you could write that line as follows:
TestConnection testconn(io_service, test_ip);
Upvotes: 4