文章标题
来源:互联网 发布:淘宝卖家账号多少钱 编辑:程序博客网 时间:2024/05/01 01:42
class animal{public: virtual void cry() = 0;};class dog :public animal{public: void cry(){ cout << "this dog is cring !!!" << endl; } void doThings(){ cout << "the dog eat stone!!!" << endl; }};class cat : public animal{public: void cry(){ cout << "this cat is cring!!!" << endl; } void doThings(){ cout << "this cat eat fish" << endl; }};void display(animal *obj){ obj->cry(); dog *d1 = dynamic_cast<dog *>(obj); if (d1!=NULL) { d1->doThings(); } cat *c1 = dynamic_cast<cat *>(obj); if (c1!=NULL) { c1->doThings(); }}int main(void){ dog d1; cat c1; display(&d1); display(&c1); animal *base1; base1 = static_cast<dog*>(&d1); base1->cry(); int a; cin >> a;}
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 如何解决PHP里大量数据循环时内存耗尽的问题
- Achartengine画分段动态曲线
- C/C++区别
- apue.h 源码
- IntelliJ IDEA 使用心得与常用快捷键
- 文章标题
- 史上最全Java集合关系图
- hdu 2537 8球胜负
- CALayer - 13
- mac电脑配置adb环境
- 1030. 完美数列(25)
- 老毛桃!至于吗!!真是无语!!!
- Java线程同步卖票问题解决方法
- RabbitMQ消息分发模式----"Hello World"模式