【发布时间】:2011-04-20 22:39:33
【问题描述】:
我有一个具有私有构造函数的类对象:
class CL_GUIComponent
{
// ...
private:
CL_SharedPtr<CL_GUIComponent_Impl> impl;
CL_GUIComponent(CL_GUIComponent &other);
CL_GUIComponent &operator =(const CL_GUIComponent &other);
CL_GraphicContext dummy_gc;
};
我有一个类,它有一个指向我之前描述的类型的对象的指针。
class Some
{
private:
CL_GUIComponent *obj;
public:
CL_GUIComponent getComp() { return *obj; }
}
但是这段代码调用错误:
In member function ‘CL_GUIComponent Some::getComp()’:
error: ‘CL_GUIComponent::CL_GUIComponent(CL_GUIComponent&)’ is private
error: within this context
如何存储和获取该对象?
【问题讨论】:
标签: c++ constructor private