【C\C++】函数传参中结构体构造析构顺序的探究
[by_041]
#include<bits/stdc++.h>
using namespace std;
struct test_1
{
test_1(){
cout<<"create\t1"<<endl;}
~test_1(){
cout<<"free\t1"<<endl;}
test_1 operator++(){
cout<<"op\t1"<<endl;return *this;}
}t1;
struct test_2
{
test_2(){
cout<<"create\t2"<<endl;}
~test_2(){
cout<<"free\t2"<<endl;}
test_2 operator++(){
cout<<"op\t2"<<endl;return *this;}
}t2;
struct test_3
{
test_3(){
cout<<"create\t3"<<endl;}
~test_3(){
cout<<"free\t3"<<endl;}
test_3 operator++(){
cout<<"op\t3"<<endl;return *this;}
}t3;
void kong(test_1 a,test_2 b,test_3 c)
{
cout<<"in kong( )"<<endl;
return;
}
int main()
{
kong(++t1,++t2,++t3);
return 0;
}