摘要: #include<bits/stdc++.h> using namespace std; /** * 基类指针操作派生类对象时,只能访问虚函数,新增成员无法访问 * */ class B { int x; public: B(int i) { x = i; } int getx() { return 阅读全文
posted @ 2021-12-27 23:41 consolexinhun 阅读(93) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> using namespace std; /** * dynamic_cast 强制类型转换,派生类对象指针转为基类对象指针 * */ class Base { public: virtual ~Base() { } }; class D :publi 阅读全文
posted @ 2021-12-27 21:56 consolexinhun 阅读(139) 评论(0) 推荐(0) 编辑