解决代码如下:
C++ 中
Base * p=new A();
Base* is = dynamic_cast(p);
return is ? true : false;
类声明如下: class Father; class Child : public Father; 然后在某处这样写: Father *aPInstance[2];//a是array的缩写,p是pointer的缩写,变量名叫instance。
即一个数组,数组的元素是指向实例的指针 aryPInstance[0] = new Father; aryPInstan... 类声明:
class Father;
class Child : public Father;
某处写:
Father *aPInstance[2];//aarray缩写ppointer缩写变量名叫instance即数组数组元素指向实例指针
aryPInstance[0] = new Father;
aryPInstance[1] = new Child;
用代码判定数组指针new指向ChildFather
我知道ChildFather类相互间【能】强转类【定】做父类用我想问我应该知道new候【直接】写"Child"【直接】写Father