子类调用父类构造函数和析构函数的顺序

2014-11-10 20:00:09 来源: 作者: 浏览: 38

  #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 <


  }


-->

评论

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