【发布时间】:2014-01-19 10:32:22
【问题描述】:
我想初始化一些类成员,但出现错误
"expected parameter declarator" ( 使用 clang++ )
使用 g++ "expected identifier before numeric constant".
所以我再次阅读了类初始化并编写了下面的代码:
#include <stdio.h>
class AAA{
public:
int l;
AAA(int i){l=i;}
};
class BBB{
bool normal;
AAA aaa=10;
AAA bbb(20);
AAA ccc{30};
AAA ddd={45};
};
int main(int argc, char **argv){printf("hello world\n");return 0;}
看来AAA bbb(20)这个语法不被接受!
这正常吗? (我使用选项 -std=c++11 )。
或者我错过了什么?
【问题讨论】:
-
也使用
AAA bbb{20};。