Dljcali
Dljcali

Reputation: 81

Passing a vector by reference through a function

I am getting a "type/value mismatch at argument 1" error on declaring the parameters of fillVector. Is there a namespace issue or just bad syntax somewhere?

#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

Upvotes: 0

Views: 84

Answers (1)

user2249683
user2249683

Reputation:

You have a local variable with the same name as the argument:

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

Upvotes: 1

Related Questions