I'm working on an x/y coordinate maze solving project.
I have a problem with my Maze object, whose data members are locations which also are objects of int row, int col and enum Direction {right down left up done}.
When I run my debugger, error messages come up that say "invalid use of this outside of non static member function" on the Maze object.
Why is this coming up? I don't understand how this message is showing if I'm not using any this->endLocation statement anywhere in my Maze.cpp file.
#include "maze-proj1.h"
using namespace std;
Maze::Maze() {
    validLocationCount = 0;
    validLocations = NULL;
    startLocation = endLocation;
}
Maze::~Maze() {
    if(validLocations != NULL) {
        delete [] validLocations;
    }
    validLocations = NULL;
    validLocationCount = 0;
}
Location Maze::getStartLocation() const {
    return startLocation;
}
bool Maze::isValidLocation(const Location &loc) const {
    int count = 0;
    for (int i = 0; i < validLocationCount; i++) {
        if (loc == validLocations[i]) {
            count++;
        }
    }
    if (count == validLocationCount){
        return true;
    }
    return false;
}
bool Maze::isEndLocation(const Location &loc) const {
    return loc == endLocation;
}
istream &operator>>(istream &is, Maze &m) {
    is >> m.validLocationCount;
    m.validLocations = new Location[m.validLocationCount];
    for(int i = 0; i < m.validLocationCount; i++){
        is >> m.validLocations[i];
    }
    is >> m.startLocation;
    is >> m.endLocation;
}
class Maze {
public:
    Maze(void);
    ~Maze();
    Location getStartLocation(void) const;
    bool isValidLocation(const Location &loc) const;
    bool isEndLocation(const Location &loc) const;
    friend istream &operator>>(istream &is, Maze &m);
private:
    Maze(const Maze &) { assert(false); }
    const Maze &operator=(const Maze &)
    { assert(false); return *this; }
    int validLocationCount;
    Location *validLocations;
    Location startLocation, endLocation;
};
#endif
 
    