Jump to content
  • Advertisement
Sign in to follow this  
lehthanis

Passing a 2d vector array as a pointer

This topic is 2531 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got a maze generator program I've been working on as a learning tool. I wanted to create a scoring mechanism for user solving, and to do that I need to know in advance what the solution is. I have code that automatically solves the maze. And I am using bitwise logic to store the state of each maze cell in my vector array.

As the user solves the maze, they are storing in the primary array their progress. I wanted to keep that, but make a duplicate vector array that has the computer's solve path's stored in it. So I figured I could pass to the function that solves the maze (and handles pathing) which array to work on via pointer. like this:


// This is the call for the users pathing in the maze
solveMaze(&glMaze)
// This is the call for the computers pathing in the maze
solveMaze(&glMazeSolution)

// ...

// Here's the function and just the line that I'm getting the error
bool solveMaze(vector<vector<int> > * maze)
{
if (((maze[CurrRow -1][CurrCol] & ALL_PATHS) == 0) && ((maze[CurrRow -1][CurrCol] & ALL_BACKS) == 0)) {
// Do Stuff
}
}


The error I'm getting is: binary '&' : 'std::vector<_Ty>' does not define this operator or a conversion to a type acceptable to the predefined operator

So is there a different/better/correct way to pass a multidimensional vector to a function as a pointer that won't cause this problem?

Thanks!!!

Share this post


Link to post
Share on other sites
Advertisement
That seemed to work. Is this what you meant:


// This is the call for the users pathing in the maze
solveMaze(glMaze)
// This is the call for the computers pathing in the maze
solveMaze(glMazeSolution)

// ...

// Here's the function and just the line that I'm getting the error
bool solveMaze(vector<vector<int> > & maze)
{
if (((maze[CurrRow -1][CurrCol] & ALL_PATHS) == 0) && ((maze[CurrRow -1][CurrCol] & ALL_BACKS) == 0)) {
// Do Stuff
}
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!