【发布时间】:2019-07-25 04:18:19
【问题描述】:
class P{
public:
P(int x,int y) { cout << "constructor called" << endl;}
};
int main ()
{
P(5,4); // constructor called
P p(5,4); // constructor called
return 0;
}
以上两个构造函数调用有什么区别?
P(5,4)如何调用构造函数?
【问题讨论】:
-
您对为什么不应该调用构造函数有什么疑问?两个示例的构造函数调用方式相同。
标签: c++ oop constructor initializer