Results 1 to 5 of 5

Thread: C++ Breakout clone problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default

    How did you define the vector 'bricks'? I noticed that you are using the variable i in the for loop to run through the columns. The problem is that the first set of brackets is used for rows not columns. I get the feeling you mixed them up.


    The vector should have been defined:

    brick bricks[NUM_ROWS][NUM_COLUMNS];

    not

    brick bricks[NUM_COLUMNS][NUM_ROWS];

    Of course this does not matter if you intentionally decided to use the rows constant to represent columns and the columns constant to represent rows, but somehow I doubt that was the case.

    If you're not sure about what I said try experimenting with the following matrix

    int matrix[3][3] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, };
    //Think of the array as the following matrix
    // 1 2 3
    // 4 5 6
    // 7 8 9
    cout < < matrix[0][1]; //prints 2
    cout < < matrix[1][2]; //prints 6
    cout < < matrix[2][2]; //prints 9
    //Thus matrix[i][j] refers to the integer element found at row i and column j
    Last edited by robfinalfantasy; 02-03-2007 at 06:48 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •