My compiler gives me this error message when I try to build the project --
Code:
1>Aisle.obj : error LNK2001: unresolved external symbol "private: static int Aisle::numberOfAisles" (?numberOfAisles@Aisle@@0HA)
1>C:\Users\Sterling\Documents\Visual Studio 2008\Projects\Gas Station\Debug\Gas Station.exe : fatal error LNK1120: 1 unresolved externals
The code for the Aisle class is
Code:
class Aisle
{
public:
Aisle(void);
~Aisle(void);
void setNumber(int);
int getNumber();
static int getNumberOfAisles();
private:
int number;
static int numberOfAisles;
};
Code:
#include "Aisle.h"
Aisle::Aisle(void)
{}
Aisle::~Aisle(void)
{}
void Aisle::setNumber(int aNum) {
number = aNum;
}
int Aisle::getNumber() {
return number;
}
int Aisle::getNumberOfAisles() {
return numberOfAisles;
}
What am I doing wrong with numberOfAisles? I declare it as a private static int, then make a static function to return it. I don't see why there is a problem.