我正在实现自己的SharedPtr和WeakPtr,有许多方法需要从WeakPtr的方法访问SharedPtr的私有成员。例如:
template<typename Resource>
WeakPtr<Resource>::WeakPtr(const SharedPtr<Resource>& rhs)
{
//how can i get access to private members of rhs there?
//only way is make them public?
//I need something like this:
resource = rhs.resource;
control_block = rhs.control_block;
}