class Foo {
public:
static const char *constant_string;
};
auto Foo::constant_string = "foo";
int main(void) {
};
编译: gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 像这样:
gcc -std=c++0x ./foo.cc
./foo.cc:6:11: error: conflicting declaration ‘auto Foo::constant_string’
./foo.cc:3:22: error: ‘Foo::constant_string’ has a previous declaration as ‘const char* Foo::constant_string’
./foo.cc:6:11: error: declaration of ‘const char* Foo::constant_string’ outside of class is not definition [-fpermissive]
这是auto
关键字的预期行为,还是 gcc+ 中的错误