下面一段c++代码中的void f1(A m)是什么意思,尤其解释一下括号里的怎么运行的
#include<iostream>usingnamespacestd;classA{public:A(){x=0;cout<<"CA0"<<endl;}A(inti){...
#include<iostream>
using namespace std;
class A{
public:
A(){x=0; cout<<"CA0"<<endl;}
A(int i){x=i; cout<<"CA1"<<endl;}
A(A &r){x=r.x; cout<<"CA2"<<endl;}
~A(){cout<<"DA"<<endl;}
private:
int x;
};
void f1(A m)
{}
void f2(A &m)
{}
int main()
{
A a;
A b(a);
f1(a);
f2(a);
} 展开
using namespace std;
class A{
public:
A(){x=0; cout<<"CA0"<<endl;}
A(int i){x=i; cout<<"CA1"<<endl;}
A(A &r){x=r.x; cout<<"CA2"<<endl;}
~A(){cout<<"DA"<<endl;}
private:
int x;
};
void f1(A m)
{}
void f2(A &m)
{}
int main()
{
A a;
A b(a);
f1(a);
f2(a);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询