更多的排隊: 我從mai結構中得到一個無法識別的'eld'。結構錯誤:即使包含它也不被識別
頭包含:
const int c=10;
struct Array
{
int n;
int els[c];
};
我得到的錯誤是:
error: request for member 'els' in 'A', which is of non-class type 'Array [(((unsigned int)(((int)a) + -0x000000001)) + 1)] {aka Array [(((unsigned int)(((int)a) + -0x000000001)) + 1)]}'
代碼:
Array arrayInp()
/* Create 2 vectors by the length defined by the user*/
{
int a,b,i;
cout<<"enter length of the first array: ";
cin>>a;
cout<<"enter length of the second array: ";
cin>>b;
Array A[a],B[b];
cout<<"insert first array:";
for (int i=0;i<a;i++)
{
cin>>A.els[i];
}
cout<<"insert second array:";
for (int i=0;i<a;i++)
{
cin>>B.els[i];
}
return A,B;
}
還有一個錯誤,我回來isent右有人可以解釋我的方式如何從函數返回數組結構? 後構建錯誤:
..\scr\main.cpp:32:10: warning: left operand of comma operator has no effect [-Wunused-value] ..\scr\main.cpp:32:10: error: could not convert '(0, ((Array*)(& B)))' from 'Array*' to 'Array' ..\scr\main.cpp:11:10: warning: unused variable 'i' [-Wunused-variable] ..\scr\main.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
這至少是目前還不清楚,我,代碼試圖實現什麼。 for循環的迭代次數不會爲數組「A」(或「B」)中的每個元素填充「els」的所有元素。是不是應該是動態的(els')成員(由用戶提供大小)?是否有原因沒有使用STL(例如'std :: vector')。 –
hmjd
2012-03-15 14:12:55