【发布时间】:2017-03-10 10:38:21
【问题描述】:
非常菜鸟的问题,我提前道歉。
我声明并初始化了一个数组 X。我使用该数组,稍后在代码中我希望 X 采用新值。
double X[2] = { 0.85, 0.15 };
//some code using X[]
X = { 0.84, 0.16 }; //--> this gives "error: assigning to an array from an initializer list"
//more code using X[]
X[] = { 0.84, 0.16 }; //--> this gives "error: expected primary-expression before ‘]’ token"
//more code using X[]
这样做的正确方法是什么?
【问题讨论】:
-
X[0]=1和X[1]=2怎么样?
标签: c++ arrays initialization