我有以下代码:
文件:Foo.h
class Foo {
friend void Bar();
};
文件:Foo.cpp
void Bar() {};
文件测试.cpp
#include "Foo.h"
int main(void) {
Bar();
return 0;
}
VS2008 编译它没有任何错误或警告。G++ 4.3.4 报告:
test.cpp: In function ‘int main()’:
test.cpp:8: error: ‘Bar’ was not declared in this scope
为什么?