I have 2 2D arrays that represent a maze
const char maze1[10][11]
and
const char maze2[20][21]
I'm trying to create 1 function to handle both mazes like so:
void solveMaze(maze[][])
{
}
and just pass the maze like solveMaze(maze1);
How would I do this with function templates?
I recently asked this question already but explicitly asked not to use function templates because I wasn't sure on how to use it, but I would like to see how it would work. (hope this isn't "abusing" the system)
You do not need and should not use templates to solve this problem. All you are doing is solving mazes of different sizes.
Templates are for the generation of a number of classes/functions that use various types.
Instead construct a class to store a maze. This class should store the dimentsions of the maze and give access to the components of that maze.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With