//大数继续,额,要吐了. Problem Description Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experience for many computer systems. This problem r
//赋值兼容性原则 #include<iostream> using namespace std; class PointA{ public: PointA(){ x = ; y = ; } void Set(){ } private: int x; int y; }; class PointB :public PointA{ public: private: int c; }; /*自己猜想: 赋值兼容性原则内部原理分析 在子类继承父类的时候,在子类的内存区域上,父类的元素会放在前面,子类的
错误的代码: 错误的结果: 错误原因分析: 在使用(1) 将pB,pC的值赋给pA的lchild和rchild时: 还未给指针变量pB和pC赋值,现在pB和pC中存的是个垃圾值 Note: (2)->(3)时,才对pB 赋值 总结: 在还未给指针变量正确赋值的情况下,就使用它的值 这就相当于: int a; int b = a; int a = 3; 此时b中的值肯定不是a中的值3 正确的代码: 正确的结果:
//多继承与赋值兼容性原则 #include<iostream> using namespace std; class Point{ public: Point(){ a = ; b = ; } int a; int b; }; class PointA { public: PointA(){ c = ; } int c; }; class PointB :public Point, public PointA{ }; void ProtectB(){ PointB pb; Point *p1