假设你正在操作一个Rectangle类.每个矩形可以通过左上角的点和右下角的点来表示.为了保证一个Rectangle对象尽可能小,你可能决定不把定义矩形范围的点存储在Rectangle类中,而是把它放入一个辅助结构体中,Rectangle中声明一个指向它的指针就可以了: class Point { // class for representing points public: Point(int x, int y); ... void setX(int newVal); void setY(i…
假设你正在操作一个Rectangle类.每个矩形可以通过左上角的点和右下角的点来表示.为了保证一个Rectangle对象尽可能小,你可能决定不把定义矩形范围的点存储在Rectangle类中,而是把它放入一个辅助结构体中,Rectangle中声明一个指向它的指针就可以了: class Point { // class for representing points public: Point(int x, int y); ... void setX(int newVal); void setY(i…
对象不使用默认析构函数 class Test { public: char cNum1; int iNum2; int* pInt; }; Test _ReturnObject() { Test stLocalObject; stLocalObject.cNum1 = 0; stLocalObject.iNum2 = 1; stLocalObject.pInt = new int; *stLocalObject.pInt = 0x55; return stLocalObject; } int m…