通过函数通过引用传递向量

时间:2013-12-21 17:22:40

标签: c++ vector

我在参数1和#34处得到"类型/值不匹配;声明fillVector参数时出错。是否存在名称空间问题或某处的语法错误?

#ifndef VECTOR_OBJECTS_H_INCLUDED
#define VECTOR_OBJECTS_H_INCLUDED


void fillVector(vector<Chest> &newChest, int x, int y)
{

ifstream load_chest;
load_chest.open("\\chest_item_inputs.txt");
char input = NULL;
int x_count = NULL;
int y_count = NULL;

while(input != 0)
{
load_chest >> input;
    if(input = '.')
    {
    x_count++;
    }
    if(input = 'C')
    {
    x = x_count;
    y = y_count;
    Chest newChest(x_count, y_count);
    newChest.pushback(newChest);
    }
    if(input = 80)
    {
    x_count = 0;
    y_count++;
    }
} load_chest.seekg (0, load_chest.beg);
}
}

#endif // VECTOR_OBJECTS_H_INCLUDED

1 个答案:

答案 0 :(得分:1)

您有一个与参数同名的局部变量:

void fillVector(vector<Chest> &newChest, int x, int y) {
   ...
   Chest newChest(x_count, y_count);
   newChest.pushback(newChest);
   ...
}