I am creating a maze game where the load function takes a file that contains a maze and returns a maze object which contains the actual maze(which is a 2d vector) and start and finish positions. The compiler does not like how I am attempting to return the maze object, I have a 2d vector created as well as the start and finish locations, I believe I am just simply screwing up the object declaration and/or the return statement.
maze is a local variable inside the load function so it will stop to exist when the function returns. The return type is a reference type so what you get when you call the load function is a reference to a no longer existing Maze object. What you probably want to do is to change the return type to Maze (not a reference).