use*_*065 1 c++ most-vexing-parse
以下代码编译.但是,如果我编写代码来test使用jar它调用方法,则会给我一个编译错误.这里真的发生了什么.
#include <iostream>
using namespace std;
class A {
public:
void test() {
cout << "working" << endl;
}
};
int main() {
A foo;
A jar();
}
Run Code Online (Sandbox Code Playgroud)
A jar();
Run Code Online (Sandbox Code Playgroud)
声明一个名为jarwithout any parameters 的函数,return类型是class的对象A.
你不能在里面声明一个函数main,因此,你得到了错误.
| 归档时间: |
|
| 查看次数: |
92 次 |
| 最近记录: |