代码是:
#include<iostream>
using namespace std;
class Integer
{
int num;
public:
Integer()
{
num = 0;
cout<<"1";
}
Integer(int arg)
{
cout<<"2";
num = arg;
}
int getValue()
{
cout<<"3";
return num;
}
};
int main()
{
Integer i;
i = 10; // calls parameterized constructor why??
cout<<i.getValue();
return 0;
}
在上面的代码中,语句i=10
调用了参数化的构造函数。你能解释一下吗?