#include <stdio.h> class xxPoint; class xPoint { public: int x; int y; public: xPoint(int xx, int yy) { x = xx; y = yy; printf("xPoint x = %d, y = %d/r/n", xx, yy); } xPoint& operator = (xPoint _xp) { x = _xp.x; y = _xp.y; return *this; } friend xPoint& operator+ (xPoint xp, xPoint xp1) { xPoint xp2(100, 100); xp2.x = xp.x + xp1.x; xp2.y = xp.y + xp1.y; return xp2; } void Display() { printf("x = %d, y = %d/r/n", x, y); } ~xPoint(){}; }; class xxPoint:public xPoint { public: int z; public: xxPoint(int x1, int y1, int z1):xPoint(x1, y1) { z = z1; printf("xxPoint x = %d, y = %d, z = %d/r/n", x1, y1, z1); } xxPoint& operator = (const xxPoint xxp) { z = xxp.z; return *this; } ~xxPoint(){}; }; int main() { xxPoint xxxp(100, 100, 200); xxPoint xxp1(1, 2, 3); xxp1 = xxxp; printf("xxp1 z = %d/r/n", xxxp.z); xPoint p(100, 200); xPoint p1(200, 300); p1.Display(); p1 = p1 + p; p1.Display(); return 1; }