Chinaunix首页 | 论坛 | 博客
  • 博客访问: 56523
  • 博文数量: 29
  • 博客积分: 667
  • 博客等级: 上士
  • 技术积分: 300
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-11 15:55
文章分类
文章存档

2012年(2)

2011年(27)

我的朋友
最近访客

分类: C/C++

2011-10-15 22:35:57

  1. #include<iostream>
  2. using namespace std;
  3.  
  4. class Base
  5. {
  6. public:
  7.          Base(){ cout << "construct in Base" << endl;}
  8.          Base (Base & b) {cout << "copy in Base" << endl;}
  9.          ~Base(){cout << "deconstruct in Base" << endl;}
  10.          int a;

  11. };

  12. class Derive: public Base
  13. {
  14. public:
  15.          Derive(){cout << "construct in Derive" << endl;}
  16.          Derive(Derive & b) {cout << "copy in Derive" << endl;}
  17.          ~Derive(){cout << "deconstruct in Derive" << endl;}
  18.          Derive getderive(Derive a) {return a;}
  19. };

  20. int main()
  21. {
  22.          Derive d;
  23.          Derive a = d.getderive(d);
  24.          return 0;
  25. }
阅读(258) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~