以下哪个示例是声明以下功能的更好方法?为什么?
void myFunction (const int &myArgument);
Run Code Online (Sandbox Code Playgroud)
要么
void myFunction (int myArgument);
Run Code Online (Sandbox Code Playgroud) class A
{
public:
A(const int n_);
A(const A& that_);
A& operator=(const A& that_);
};
A::A(const int n_)
{ cout << "A::A(int), n_=" << n_ << endl; }
A::A(const A& that_) // This is line 21
{ cout << "A::A(const A&)" << endl; }
A& A::operator=(const A& that_)
{ cout << "A::operator=(const A&)" << endl; }
int foo(const A& a_)
{ return 20; }
int main()
{
A a(foo(A(10))); // This is line 38
return 0;
}
Run Code Online (Sandbox Code Playgroud)
执行此代码给出了o/p:
A :: …