【发布时间】:2011-11-09 19:11:01
【问题描述】:
以下 sn-p 无法用 Visual Studio 2010 编译,但 GCC 喜欢它:
namespace Test {
class Baz;
// Adding class Bar; here and removing the class below makes it work
// with VC++, but it should work like this, shouldn't it?
void Foo (Baz& b, class Bar& c);
}
namespace Test {
class Bar
{
// Making this method non-template works
template <typename T>
static void Lalala ()
{
}
};
}
int main ()
{
}
我是在做一些愚蠢的事情还是这是一个有效的编译器错误?我得到的错误是:
error C2888: 'void Bar::Foo(void)' : symbol cannot be defined within namespace 'Test'
它使用 GCC 4.5.1 编译:http://ideone.com/7sImY
[编辑] 为了清楚起见,我想知道这是否是有效的 C++(如果是,为什么不)——编译它的解决方法很好,但不是这个问题的一部分。
【问题讨论】:
标签: c++ visual-c++ compiler-errors compiler-bug