Wednesday, August 29, 2012

copy ctor of member object


#include <iostream>


struct A{
  A(){std::cout<<"basic cted"<<std::endl;}
  A(const A& a){
    std::cout<<"copy cted"<<std::endl;
  }

};


struct B{
  A a;
  int x;
};


int main(){
  B b1;
  std::cout<<"now b2"<<std::endl;
  B b2=b1;
}

===OUTPUT===

basic cted
now b2
copy cted


No comments:

Post a Comment