我有两个班级:Point只住在Space
class Point
{
private:
Point(const Space &space, int x=0, int y=0, int z=0);
int x, y, z;
const Space & m_space;
};
Run Code Online (Sandbox Code Playgroud)
构造函数是故意私有的,我不希望它被直接调用.我想用这种方式创建点数
Space mySpace;
Point myPoint = mySpace.Point(5,7,3);
Run Code Online (Sandbox Code Playgroud)
有没有办法这样做?谢谢.
c++ ×1