Sol*_*Out 3 c++ static constructor structure initialization
我的问题:当一个结构有c-tor时,为什么我不能静态初始化它?
我的编译器声称:
type `myStruct' must be initialized by constructor, not by `{...}'
Run Code Online (Sandbox Code Playgroud)
这是为什么 ?我正在使用gcc版本3.4.4(cygming special,gdc 0.12,使用dmd 0.125)
为了说明,这是struct编译器拒绝的.
struct myStruct
{
int a;
double b;
myStruct() { a= 0; b = 0.0; }
}
void main()
{
myStruct ms = {7, 7.7}; // Now this compiler does not accept.
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
357 次 |
| 最近记录: |