Error: no match for operator<<

Everything else seems to compile without error, what is wrong with my code, im new so i know it my code isnt the greatest.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <vector>


int main(int argc, char** argv){

    std::vector<std::vector<int> > vectorOne(64,1);

    for ( int row1 = 0; row1 < 8; row1++){
        for ( int row2 = 0; row2 < 8; row2++){
            std::cout << "At: " << row1 << "Element: " << row2 << " " << vectorOne[row2];
        }
    }

    return 0;
}

You are using subscripting operator only once only once on a 2d vector
Two things, how would your recommend fixing that, and the error is on line 11 sorry for not mentioning it, and thanks for the help.
I don't get what you are trying to do, you have a vector filled with 64 vectors
( line 7 should not compile unless you call the explicit constructor: std::vector<std::vector<int> > vectorOne ( 64,vector<int>(1) ); )
But you are then looping as if you were expecting an 8x8 2D vector
Ah sorry, I thought in vectors that 64 meant 64 elements in total, from the 8 x 8, at this point im just trying to get it to compile with printing out 64 1s, then id worry about changing whats inside.
You need only one vector then:
std::vector<int> vectorOne(64,1);

... << vectorOne[row1+8*row2];
Last edited on
Topic archived. No new replies allowed.