class ARouter {
enum directions {north, neast, east, seast, south, swest, west, nwest};
static directions gon[] = {north, neast, nwest, east, west, seast, swest, south};
};
大家好,有人知道上面的代码出了什么问题吗?
我在VC++2008Ex中对第二行代码出现了两个错误:
error C2059: 语法错误 : '{'
error C2334: 在“{”之前有意外的标记;跳过表象函数体
a brace-enclosed initializer is not allowed here before ‘{’ token
和invalid in-class initialization of static data member of non-integral type ‘ARouter::directions []’
。这是使用g++ 4.5.2、4.1.2、4.2.1、3.0.4、2.8.1和其他一些版本时出现的情况(错误随着旧版本而变化)。Solaris的“CC”也会报错。你们其他人是如何编译而没有出现错误的?(不,原始问题并没有被编辑过。) - Keith Thompson