复制代码
err:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20class Foo { public: Foo() {}; Foo(int a) {}; void bar() {}; }; int main() { // this works... Foo foo1(1); foo1.bar(); // this does not... Foo foo2(); foo2.bar(); return 0; }
复制代码
1
2nonclass.cpp: In function ‘int main(int, const char**)’: nonclass.cpp:17: error: request for member ‘bar’ in ‘foo2’, which is of non-class type ‘Foo ()()’
原因:
because compiler thinks of
Foo foo2()
as of function declaration with name 'foo2' and the return type 'Foo'.
最后
以上就是唠叨服饰最近收集整理的关于使用Foo f2();f2.bar();带来的问题的全部内容,更多相关使用Foo内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复