我在我的书下面的语句:
编译器何时不创建默认构造函数?
如果我们给予任何构造了一类无论是
1.我们自己explcit默认构造函数(即无参数或具有默认 参数值)
或
2.我们自己的构造函数的参数
那么编译器不会产生隐含的默认构造要么。
但我对第2点有怀疑,我怀疑我的书籍ID不正确或过时,因为我的下面的代码确实有一个带参数的构造函数,但编译器也在生成内部构造函数。
#include <iostream>
class imminent{
public:
imminent(int x, int y){
std::cout << "I am explicit constructor" << std::endl;
}
};
int main(){
imminent gilfray(); /* compiler creates internal default constructor
that why this line is compiled without errors*/
imminent jimmy(1, 2);
}
而且,我怎样才能把我的C++代码在这里,因为这一次我是被迫的代码片段用JS真正的出路,是不是有任何的C++代码共享选项?
看看最烦人的解析:http://en.wikipedia.org/wiki/Most_vexing_parse。 '即将gilfray();'是一个函数返回'迫在眉睫' – 2014-11-24 18:19:41