I swear I've done this a hundred times before, but, I need a member function that returns an object of the type of class that I'm creating. I though I fixed this problem in the past with forward declaration, but things aren't working (compiling) right now. Perhaps you can shed some light. Here is my code:
Code:
#ifndef LOCATION_H
#define LOCATION_H
#include<vector>
using namespace std;
class Location; // Forward Declaration
class Location
{
private:
int row, col, cost;
Location history; // This is the problem line
public:
Location()
{ row = col = 0; }
Location(int r, int c)
{ row = r; col = c; }
int getRow()
{ return row; }
int getCol()
{ return col; }
int getCost() const
{ return cost; }
void setCost(int c)
{ cost = c; }
void setHistory(Location loc)
{ history = loc; }
Location getHistory()
{ return history; }
bool operator < (const Location& loc) const
{ return (cost > loc.getCost()); }
};
#endif
Andrew