设为首页 加入收藏

TOP

子类调用父类构造函数和析构函数的顺序
2014-11-10 20:00:09 】 浏览:3598
Tags:子类 调用 构造 函数 顺序

  #include


  class B


  {


  public:


  B(); //与类同名,构造函数


  B(int i);


  ~B(); //~析构函数


  void Print() const;//const,常量成员,不能修改


  private:


  int b;


  };


  B:B()


  {


  b=0;


  cout < < "B 's default constructor called. " <


  }


  B::B(int i)


  {


  b=i;


  cout < < "B 's constructor called. " <


  }


  B::~B()


  {


  cout < < "B 's destructor called. " <


  }


  void B:Print() const


  {


  cout <


  }


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C#和C++结构体Socket通信 下一篇Dll导出函数引用Dll外部函数声明

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目