Class in a h file plz help
Hi All,
I'm having a bit of trouble linking my header file that has my class definitions in with my cpp method file which has all of the methods. My compiler keeps giving me errors like as if the definitions don't exist. Here's some sample code below...
classes.h
<code>
class elevator //define elevator class
{
int level;
int peoplein;
public:
void initialize(void);
void go_up(void);
void go_down(void);
void next_floor(void);
void open_doors(void);
void close_doors(void);
};
class building //define building class (manager)
{
elevator elevator1;
person person1;
public:
bool closed;
void initialize(void);
};
</code>
and in my methods cpp...
meth.cpp
<code>
void elevator::initialize(void)
{
level = 1;
peoplein = 0;
cout << "Floor " << level << "..." << endl;
}
void elevator::open_doors(void)
{
//Check if people need to come aboard, if so aboard them.
}
void elevator::close_doors(void)
{
char key;
cout << "Hit a key to close the lift doors...(Q to quit)"<< endl;
cin >> key;
if(key = 'q')
elevator.closed = 1;
}
void elevator::next_floor(void)
{
if (level ==20)
elevator::go_down();
else
elevator::go_up();
}
void elevator::go_up(void)
{
cout << "Going up..." << endl;
level++
cout << "Floor " << level << endl;
}
void elevator::go_down(void)
{
cout << "Going down..." << endl;
level--
cout << "Floor " << level << endl;
}
</code>
The compiler errors basically say that when compiling the h, meth.cpp and the main.cpp file (which has the inclusion statment to the h file) that it doesn't know any of the variables in meth.cpp such as level, elevator.closed etc.
Any Help would greatly be appreciated!
Thanks.
Best Regards,
Smithy.