その他の質問: マイ構造から認識されない 'フィールド'が表示されます。構造エラー:含まれていても認識されません
ヘッダが含まれています
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