一个对象构造两次,析构两次
1 #include<iostream> 2 int n=0; 3 using namespace std; 4 class Cbox{ 5 int a ; 6 int b ; 7 int c ; 8 public: 9 int g ; 10 Cbox(int d):a(d),c(d),b(d){cout<<"dddd"<<endl;} 11 Cbox(){cout<<"dddd"<<endl;}; 12 ~Cbox(){cout<<a<<" "<<b<<" "<<c<<endl;} 13 }; 14 15 16 17 int main(){ 18 int aa=10; 19 Cbox a ; 20 a=aa; 21 //Cbox b(a);//跟 Cbox b=a; 结果一样 22 23 24 25 26 27 } 28