为什么构造函数不使用函数调用运算符调用
Why Constructor is not Calling with Function call Operators
抱歉,我找不到任何关键字来搜索此问题。我的代码如下
#include <iostream>
using namespace std;
class Name {
public:
Name() {
cout << "Asif";
}
};
int main() {
Name obj(); // why Constructor not calling here?
return 0;
}
如果不是调用构造函数那么这段代码中运行是什么进程?
Name obj(); // why Constructor not calling here?
这是一个函数声明,返回一个Name对象
就这样
Name obj;
抱歉,我找不到任何关键字来搜索此问题。我的代码如下
#include <iostream>
using namespace std;
class Name {
public:
Name() {
cout << "Asif";
}
};
int main() {
Name obj(); // why Constructor not calling here?
return 0;
}
如果不是调用构造函数那么这段代码中运行是什么进程?
Name obj(); // why Constructor not calling here?
这是一个函数声明,返回一个Name对象
就这样
Name obj;