/*
赋值兼容规则
*/ #include <iostream> #include <vector> using namespace std; class Base{ private: int x; int y; public: Base(int x,int y) { this->x=x; this->y=y; } }; class Derived:public Base{ private: int z; public: Derived(int z):Base(z-1,z+1) { this->z=z; } }; int main(void) { //Derived *p=new Base(2,1);//因为派生类指针映射范围大 Base *p=new Derived(1); delete p; return 0; }