2-D Vectors

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:
1
2
3
4
5

Grid exampleGrid();

exampleGrid.output(cout);


grid default constructor:
1
2
3
4
5
6
7
8
9
10
11

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:
1
2
3
4
5
6
7
8
9
10

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!
Last edited on
Could you post your class definition? I don't see anything wrong with what you have there.
Grid::Grid(Grid &grid_Cp)
should be

Grid::Grid(const Grid &grid_Cp)

but other than that I don't see anything (but I didn't look all that closely)
Topic archived. No new replies allowed.