I am attempting to create a class that uses a vector of vectors to store a "grid" of integers. I am having some trouble getting it to work and I was hoping someone could help me out. My constructor should initialize the grid with 0s. This is compiling though I am not sure that it is working correctly. I wanted to test this by implementing an output method to display the grid contents. The program is compiling, though a call to the output method from main results in an error:
Request for member 'output' in 'initialGrid', which is of non-class type 'Grid()()'
call to output in main:
Code:
Grid exampleGrid();
exampleGrid.output(cout);
grid default constructor:
Code:
Grid::Grid()
{
for (int f=0; f<10; f++) {
Grid_.push_back(vector<int>());
for (int g=0; g<10; g++) {
Grid_[g].push_back(0);
}
}
}
output method:
Code:
void Grid::output(ostream &out) const
{
for (int f=0; f<10; f++) {
for (int g=0; g<10; g++) {
out << Grid_[f][g];
}
}
}
Thanks!