error using 2d vectors in C++, PLEASE HELP!

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Sphinx

Thread Starter
Joined
Aug 5, 2003
Messages
606
ok heres the scenario. This is my code in a function that copies a 2-d vector into a new 2-d vector:
1) n is a private class variable that holds the size of the grid of the class object (The size is actually n squared).
2) grid1 is a 2d vector class variable that holds the grid itself of the class object. It is defined in the form of vector <vector<int> > grid1;

The following is a code for a copy constructor that passes "grid2" as a parameter, which is the 2d vector to be copied.
---------------------------------
n=grid2.n();
vector<int> ss(n^2);

for(int i=0;i<(n^2);i++){
grid1.push_back(ss);
}

for(i=0;i<(n^2);i++){

for(int j=0;j<(n^2);j++){


grid1[j] = grid2[j];
}

}


I am getting the following error:

...\Sudoku.cpp(33): error C2676: binary '[' : 'const Sudoku' does not define this operator or a conversion to a type acceptable to the predefined operator
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top