设为首页 加入收藏

TOP

子类调用父类构造函数和析构函数的顺序
2014-11-10 20:00:09 来源: 作者: 【 】 浏览:35
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外部函数声明

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: