Grid::Grid(Hex* current)
{
int run = current->calculateMapSpace(current->getXRun(), current->getYRun());
int rowPush = 0;
hexGrid.push_back(current);
for (int i = 1; i < run; i++)
{
// check to see if i go up or down
if (hexGrid.at(i-1)->getInBounds())
{
if (i % 2 == 0)
{
//go up
hexGrid.push_back(new Hex(hexGrid.at(i - 1)->getXPos() + 30, hexGrid.at(i - 1)->getYPos() + 30, hexGrid.at(0)->getTool()));
hexGrid.at(i)->setXCoor(hexGrid.at(i-1)->getXCoor() + 1);
hexGrid.at(i)->checkbounds(hexGrid.at(0)->getXRun(), hexGrid.at(0)->getYRun());
}
else
{
//go down
hexGrid.push_back(new Hex(hexGrid.at(i - 1)->getXPos() + 30, hexGrid.at(i - 1)->getYPos() - 30, hexGrid.at(0)->getTool()));
hexGrid.at(i)->setXCoor(hexGrid.at(i - 1)->getXCoor() + 1);
hexGrid.at(i)->checkbounds(hexGrid.at(0)->getXRun(), hexGrid.at(0)->getYRun());
}
}
else
{
// start new row
rowPush++;
hexGrid.push_back(new Hex(20, 30 + (rowPush * 60), hexGrid.at(0)->getTool()));
hexGrid.at(i)->setXCoor(1);
hexGrid.at(i)->setYCoor(hexGrid.at(i-1)->getYCoor() + 1);
hexGrid.at(i)->checkbounds(hexGrid.at(0)->getXRun(), hexGrid.at(0)->getYRun());
}
}
}
the first 5 errors in the error list are:
Error 1 error C2516: '_Alloc' : is not a legal base class c:\program files (x86)\microsoft visual studio 12.0\vc\include\xmemory0 749 1 P2
Error 2 error C2825: '_Alloc': must be a class or namespace when followed by '::' c:\program files (x86)\microsoft visual studio 12.0\vc\include\xmemory0 419 1 P2
Error 3 error C2039: 'value_type' : is not a member of '`global namespace'' c:\program files (x86)\microsoft visual studio 12.0\vc\include\xmemory0 419 1 P2
Error 4 error C2146: syntax error : missing ';' before identifier 'value_type' c:\program files (x86)\microsoft visual studio 12.0\vc\include\xmemory0 419 1 P2
Error 5 error C2602: 'std::allocator_traits<_Alloc>::value_type' is not a member of a base class of 'std::allocator_traits<_Alloc>' c:\program files (x86)\microsoft visual studio 12.0\vc\include\xmemory0 419 1 P2
I have found the source of my woes, however very unexpected and a bit confusing. After ensuring all the #include (Thanks again coder777) were, to the best of my knowledge, correct, I began to look at why they were there in the first place. In the header Hex.h the following makes the compiler go *KABLAM*:
std::vector<int, int> hexVect;
Though I am glad it now builds, I still seek the answers to why and how that is wrong (rather what I did to make it wrong). Below is the Hex.h in it's entirety... it's a bit messy
by writing std::vector<int, int> hexVect; you told the compiler to create a vector whose element type is int and whose allocator type is int. There are many requirements on what the allocator type must be ( http://en.cppreference.com/w/cpp/concept/Allocator ), and one of that is that it must be a class with a member called value_type. Your compiler assumed that it was true and ran into errors: "'_Alloc' : is not a legal base class" and "std::allocator_traits<_Alloc>::value_type' is not a member".
When the new C++ language extension called "Concepts" becomes part of the language and library (already supported in gcc trunk for the language part, but not yet for the lbirary), the error on your vector<int, int> line would be simply "int does not meet the requirements of Allocator". Until then, learning to read template instantiation error messages is a difficult, but valuable skill.