int q) : x(p), y(q) {} friend class Point3D; }; class Point3D { int x; int y; int z; public: Point3D(int p, int q, int r) : x(p), y(q), z(r) {} Point3D(const Point2D &point2D) : x(point2D.x), y(point2D.y), z(0) {} friend ostream& operator<<(ostream& os, const Point3D& point); }; ostream& operator<<(ostream& os, const Point3D& point) { os << "(" << point.x <<", " << point.y << ", " << point.z << ")"; return os; } int main() { Point2D point2D(3, 4); cout << point2D << endl; return 0; }