The other errors are actually from similar code; warnings are from comparing unsigned int to int. The function I am writing is to open a file at filename. This file might look something like this:
0 0 0 2 3 4 -1
0 0 3 4 5 -1
0 0 6 -1
I am just having issues pushing the int I read in into the vector. I am unsure why it is not working.
Code:
vector<vector<int> > Modifier_Levels; //from the class' header
void Item_Gen::Load_Modifier_Tables(string filename)
{
int input;
ifstream in;
in.open(filename.c_str());
Modifier_Levels.push_back(vector<int>()); //add an empty row
while(!in.eof())
{
in>>input;
if(input != -1)Modifier_Levels.push_back(input); //add a value to the current modifier level
else if(!in.eof())Modifier_Levels.push_back(vector<int>()); //if there is still another level to read in add a line for it.
}
}
Code:
C:\Users\David\Desktop\Server code A\Glory\Item_Generator.cpp||In member function 'void Item_Gen::Load_Modifier_Tables(std::string)':|
C:\Users\David\Desktop\Server code A\Glory\Item_Generator.cpp|62|error: no matching function for call to 'std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >::push_back(int&)'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\bits\stl_vector.h|733|note: candidates are: void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = std::vector<int, std::allocator<int> >, _Alloc = std::allocator<std::vector<int, std::allocator<int> > >]|
C:\Users\David\Desktop\Server code A\Glory\Item_Generator.cpp|63|error: no matching function for call to 'std::vector<int, std::allocator<int> >::push_back(std::vector<int, std::allocator<int> >)'|
c:\program files (x86)\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\bits\stl_vector.h|733|note: candidates are: void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = int, _Alloc = std::allocator<int>]|
||=== Build finished: 4 errors, 2 warnings ===|