从“CSon *”到“CFather *”的变换存在,但无法访问,why
从“CSon *”到“CFather *”的转换存在,但无法访问,why?
代码如下,问题如题,求讲解,谢谢大家
------解决方案--------------------
class CSon:public CFather
------解决方案--------------------
因为CSON的构造函数进不去
------解决方案--------------------
代码如下,问题如题,求讲解,谢谢大家
- C/C++ code
#include <iostream> using namespace std; class CFather { private: int age; public: int money; public: CFather() { } ~CFather() { } }; class CSon:CFather { public: CSon() { } ~CSon() { } }; int main() { CFather *son = new CSon; system("pause"); return 0; }
------解决方案--------------------
class CSon:public CFather
------解决方案--------------------
因为CSON的构造函数进不去
------解决方案--------------------