多态 C2

  
class apple {
public:
  ~apple(){ std::cout << "~apple()" << std::endl;}
};

class banana : public apple {
  ~banana(){ std::cout << "~banana()" << std::endl;}
};

class cat {
  virtual ~cat(){ std::cout << "~cat()" << std::endl;}
}; 

class dog : public cat {
  ~dog(){ std::cout << "~dog" << std::endl;}
};

int main(void)
{
  banana* pa1 = new banana;
  delete pa1;

  banana* pa2 = new banana;
  delete (apple*)pa2;

  dog* pd1 = new dog;
  delete pd1;

  dog* pd2 = new dog;
  delete (cat*)dog;  
}

  

时间: 2024-10-07 21:49:37

多态 C2的相关文章

PHP技术基础

1.php4种标签风格及3种注释风格 i.标签风格 a.XML风格 <?php echo "hello world!"; ?> b.ASP风格 <% echo "hello world!"; %> c.脚本风格 <script language="php"> echo "hello world!"; </script> d.极简风格 <?echo "hello w

年巨化股份风格和进口量客家话规范

http://www.gettyimages.cn/newsr.php?thekeyword=%A1%ED%BD%FA%BD%AD%C4%C4%C0%EF%D3%D0%B4%DF%C7%E9%D2%A9%C2%F4Q%A3%BA%A3%B2%A3%B0%A3%B8%A3%B6%A3%B0%A3%B6%A3%B7%A3%B5%A9I http://www.gettyimages.cn/newsr.php?thekeyword=%A1%BC%CA%AF%CA%A8%C4%C4%C0%EF%D3%D0

u解药农行吧个v分

http://ypk.39.net/search/all?k=%A1%FD%C1%AC%BD%AD%C4%C4%C0%EF%C2%F2%C7%E8%BB%AF%BC%D8Q%A3%BA%A3%B1%A3%B1%A3%B2%A3%B7%A3%B4%A3%B0%A3%B1%A3%B1%A3%B7%A3%B5%A8y http://ypk.39.net/search/all?k=%A8%E8%B3%A4%C0%D6%C4%C4%C0%EF%C2%F2%C7%E8%BB%AF%BC%D8Q%A3%BA%

67听觉与夫人呢

http://quote.hexun.com/stock/icb.aspx?code=1&name=%A1%B9%D9%F0%D6%DD%C4%C4%C0%EF%D3%D0%C7%E8%BB%AF%CE%EF%C2%F4%A3%D1%3A%A3%B2%A3%B0%A3%B8%A3%B6%A3%B0%A3%B6%A3%B7%A3%B5 http://quote.hexun.com/stock/icb.aspx?code=1&name=%20%D6%EE%B3%C7%C4%C4%C0%EF%D

8一盒

http://www.bookba.net/search-novel-www.sporttery.cn%A8%8B%C3%E0%D6%F1%C3%D4%BB%E8%D2%A9%C4%C4%C0%EF%C2%F2Q%A3%BA%A3%B6%A3%B9%A3%B5%A3%B2%A3%B5%A3%B6%A3%B7%A3%B1%A3%B7.html http://www.bookba.net/search-novel-www.sporttery.cn%A1%C9%BD%AD%D3%CD%C3%D4%BB

677就

http://www.bookba.net/search-novel-www.sporttery.cn%A8y%B7%F0%C9%BD%C4%C4%C0%EF%D3%D0%C2%F4%C3%D4%D2%A9Q%A3%BA%A3%B6%A3%B9%A3%B5%A3%B2%A3%B5%A3%B6%A3%B7%A3%B1%A3%B7.html http://www.bookba.net/search-novel-www.sporttery.cn%20%BD%AD%C3%C5%C4%C4%C0%EF%D

太经济体据统计图

http://ypk.39.net/search/all?k=%20%D6%DB%C9%BD%C4%C4%C0%EF%C2%F2%C3%C0%C9%B3%CD%AAQ%A3%BA%A3%B2%A3%B0%A3%B8%A3%B6%A3%B0%A3%B6%A3%B7%A3%B5%A1%DE http://ypk.39.net/search/all?k=%A8r%CC%A8%D6%DD%C4%C4%C0%EF%C2%F2%C3%C0%C9%B3%CD%AAQ%A3%BA%A3%B2%A3%B0%A3%

简笔画规范的的风格和进口量

http://shike.gaotie.cn/zhan.asp?zhan=%A1%BB%BD%FA%BD%AD%C4%C4%C0%EF%D3%D0%B4%DF%C7%E9%D2%A9%C2%F4Q%A3%BA%A3%B2%A3%B0%A3%B8%A3%B6%A3%B0%A3%B6%A3%B7%A3%B5%A1%BA http://shike.gaotie.cn/zhan.asp?zhan=%A2%D9%CA%AF%CA%A8%C4%C4%C0%EF%D3%D0%B4%DF%C7%E9%D2%A9

OC多态,动态类型绑定

// //  main.m //  OC7类 // //  Created by Zoujie on 15/8/23. //  Copyright (c) 2015年 Zoujie. All rights reserved. // #import <Foundation/Foundation.h> #import "Fraction.h"//导入头文件 #import "Complex.h" #define Choose  0 int main(int