【发布时间】:2018-11-22 02:17:52
【问题描述】:
class A
{
public:
A() { cout << "constructor" << endl; };
A(const A &) { cout << "copy constructor" << endl; };
void operator()(int a, int b) { cout << "a+b" << endl; }
};
void set(A visit) {
visit(1, 2);
}
int main()
{
set(A());
return 0;
}
A() 构造函数直接创建对对象的访问,该对象由隐式对象传递给 set 参数。构造函数也有创建对象的能力?
【问题讨论】:
标签: c++ object constructor