iam*_*ind 12 c++ in-class-initialization c++11
在类初始化功能中,它允许在类本身内初始化普通成员,
struct A {
int a = 0; // error: ISO C++ forbids in-class initialization of non-const static member ‘a’
};
Run Code Online (Sandbox Code Playgroud)
这在最新的编译器gcc-4.6(with -std=c++0x)中给出了错误.将此功能制作成C++ 11标准还是gcc仍然不支持它?
Jam*_*lis 23
是的,这在C++ 0x中是合法的.在N3290§12.6.2/ 8中有一个例子:
struct C {
/* ... */
int j = 5; // OK: j has the value 5
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5247 次 |
| 最近记录: |