C++ 下标值不是数组、指针或向量C++;

C++ 下标值不是数组、指针或向量C++;,c++,arrays,C++,Arrays,因此,我得到了上面的错误(在标题中),但出于某种原因,它只是在第二个循环中抛出这个错误。注意,我使用customer变量的第一个和第二个循环工作得非常好,没有抛出错误或其他任何东西。但在最后一个循环,输出[customer][charge]数组中,在输出[customer]下面有一条红线,表示“下标值不是数组、指针或向量”。我使用的是xcode,Mavericks OSX。我所有的数组都是在别处定义的,在程序的整个过程中一直工作得很好。程序中还有其他一些操作,但是它们与这个循环无关,所以我只是发

因此,我得到了上面的错误(在标题中),但出于某种原因,它只是在第二个循环中抛出这个错误。注意,我使用customer变量的第一个和第二个循环工作得非常好,没有抛出错误或其他任何东西。但在最后一个循环,输出[customer][charge]数组中,在输出[customer]下面有一条红线,表示“下标值不是数组、指针或向量”。我使用的是xcode,Mavericks OSX。我所有的数组都是在别处定义的,在程序的整个过程中一直工作得很好。程序中还有其他一些操作,但是它们与这个循环无关,所以我只是发布了给出错误的代码。再说一遍,charges[customer][month][charge]循环工作正常,但是输出[customer][output]不工作

另外,你可能会认为将所有这些数据保存在数字索引数组中的逻辑是愚蠢的,但这是一个学校项目。所以不要告诉我这个程序在逻辑上是如何不一致的。谢谢

string headings[3][7];
string chargeLabels[3] = {"Electricity :","Water: ","Gas: "};
string outputLabels[5] = {"Subtotal: ","Discount: ","Subtotal: ","Tax: ","Total: "};
double charges[3][3][3];
double output[3][5];

for(int customer=0; customer<3; customer++)
{
    for(int heading=0; heading<5; heading++)
    {
        cout << headings[customer][heading];
    }

    for(int month=0; month<3; month++)
    {
        cout << chargeLabels[month];

        for(int charge=0; charge<3; charge++)
        {
            cout << charges[customer][month][charge] << ", ";
        }
        cout << endl;
    }
    for(int output=0; output<5; output++)
    {
        cout << outputLabels[output];
        //error is below this comment
        cout << output[customer][output] << endl;
    }
}
字符串标题[3][7];
字符串标签[3]={“电:”、“水:”、“气:”};
字符串outputLabels[5]={“小计:”、“折扣:”、“小计:”、“税:”、“总计:”};
双重收费[3][3][3];
双输出[3][5];

for(int customer=0;customer在
for
语句中:

for(int output=0; output<5; output++)
{
for(int-output=0;output这是您的问题:

double output[3][5];
for(int output=0; output<5; output++)
您正在访问本地
输出
,它只是一个int

cout << output[customer][output] << endl;