1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

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

Discussion in 'Software Development' started by Sphinx, Feb 9, 2007.

Thread Status:
Not open for further replies.
  1. Sphinx

    Sphinx Thread Starter

    Aug 5, 2003
    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.
    vector<int> ss(n^2);

    for(int 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
  2. Shadow2531


    Apr 30, 2001
    Do you really want n ^ 2 or do you want n * n?
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 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/542527

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice