I have two classes : Point, that lives only in Space
class Point
{
private:
Point(const Space &space, int x=0, int y=0, int
I would do it like this:
class Space
{
public:
class Point
{
private:
Point(const Space &space, int x=0, int y=0, int z=0);
int m_x, m_y, m_z;
const Space & m_space;
friend class Space;
};
Point MakePoint(int x=0, int y=0, int z=0);
};
Space::Point::Point(const Space &space, int x, int y, int z)
: m_space(space), m_x(x), m_y(y), m_z(z)
{
}
Space::Point Space::MakePoint(int x, int y, int z)
{
return Point(*this, x, y, z);
}
Space mySpace;
Space::Point myPoint = mySpace.MakePoint(5,7,3);