错误"数组可能没有这种类型的&QUOT的元素; [英] Error "An array may not have elements of this type"
问题描述
I`ve问题,因为编译这个奇怪的编译错误的我的程序...这里是code的具体部分:
//错误occures在CHAR _ADR [] [],在构造函数的参数地址(字符串_ime,串_egn,字符* _adres,焦炭_ADR [] [],诠释adrLen):人(_ime,_egn,_adres){
addressLength = 0;
为(; addressLength&下; adrLen; addressLength ++){
如果(addressLength> = 5){
打破;
}
ADR [addressLength] = _ADR [addressLength]
}
}
在C / C ++,你不能定义有两个未知大小的双维数组作为字符_ADR [] []
。阵列声明必须具有所有,但第一,尺寸限定。尝试界定至少一个尺寸(例如:字符_ADR [] [10]
),或者,因为你使用的是C ++,使用的 的std ::矢量
来代替。
只是为了让你注意到它:您还使用了 ADR
不会在功能范围宣布它
I`ve problem compiling my program because of this strange compile error...here is the concrete part of code:
// the error occures at "char _adr[][]" in the constructor parameters
Addresses(string _ime, string _egn, char *_adres, char _adr[][], int adrLen):Person(_ime, _egn, _adres){
addressLength = 0;
for(; addressLength < adrLen; addressLength++) {
if(addressLength >= 5){
break;
}
adr[addressLength] = _adr[addressLength];
}
}
In C/C++ you cannot define a bi-dimensional array with two unknown size as in char _adr[][]
. Arrays declarations must have all, but the first, sizes defined. Try defining at least one size (example: char _adr[][10]
) or, since you are using C++, use an std::vector
instead.
Just to make you notice it: you are also using the adr
without declaring it in the scope of the function.
这篇关于错误&QUOT;数组可能没有这种类型的&QUOT的元素;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!