AB是一个类,那么执行语句“AB a(4), b[3], *p ;”调用了()次构造函数?
A 2 B 3 C 4 D 5
#include <iostream>
using namespace std;
class AB
{
public:
AB()
{
cout << "ctor" << endl;
}
AB(int x)
{
cout << "ctor" << endl;
}
};
int main()
{
AB a(4), b[3], *p ;
return 0;
}
ctor
ctor
ctor
ctor
所以是4次。