bachra04
asked on
Initialize reference member with default value
Hi This is what I want do in my class ProtocolInfo:
I have two contructors :
ProtocolInfo();
ProtocolInfo(boost::asio:: io_service & pIo_service);
when my client calls ProtocolInfo, internally I creates a new ProtocolInfo object and assign to its internal member variable :
boost::asio::io_service& m_pIo_service; a value which can only be passed in initialization list.
My question is how to creates the original ProtocolInfo with default value since a reference member cannot be initialized with NULL reference in c++?
I have two contructors :
ProtocolInfo();
ProtocolInfo(boost::asio::
when my client calls ProtocolInfo, internally I creates a new ProtocolInfo object and assign to its internal member variable :
boost::asio::io_service& m_pIo_service; a value which can only be passed in initialization list.
My question is how to creates the original ProtocolInfo with default value since a reference member cannot be initialized with NULL reference in c++?
ASKER
the problem is that I cannot use the operator = (boost::io_service is not copyable only through initalization list).
Also the when the client does that :
ProtocolInfo info;
here I want internally to call the constructor :
ProtocolInfo(),
:m_pIo_service(defaultServ ice)...
but where in the code I declare it ?
Thanks,
Also the when the client does that :
ProtocolInfo info;
here I want internally to call the constructor :
ProtocolInfo(),
:m_pIo_service(defaultServ
but where in the code I declare it ?
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window