在二维数组中插入struct

时间:2012-06-18 10:50:28

标签: c++ arrays struct

当我尝试在二维数组中添加struct

cin>>array[1][items.stoka_ime];
错误列表中的

写下:

    IntelliSense: no operator "[]" matches these operands

1 个答案:

答案 0 :(得分:-3)

从你的问题不清楚你的实际问题是什么。所以我只是展示一个数组和结构组合使用的样本。

对于结构数组

struct abc
{
int i;
int j;
}

abc object[10];

cin>>object[0].i>>object[0].j;

结构中的数组

struct abc
    {
      int i[10];
    }         
 abc object;                  
 cin>>object.i[0];

用于推入结构的队列数组:

queue.push(array[i]);
相关问题