DrDeThuong
10-10-2002, 11:08 PM
Hi, I need some help ...
There is a base class employee, and 2 others class (manager, laborer) which are derived from class employee.
=================================
=================================
// file employee.h
// class employee defination
class employee {
// body here
};
--------------------------
// file employee.cpp
// implementation for class employee.
#include "employee.h"
// blab blab blab...
// end of employee.cpp
=================================
=================================
// file manager.h
// class manager defination
#include "employee.h"
class manager : public employee{
// body here
};
------------------------------------
// file manager.cpp
// implementation for class manager.
#include "manager.h"
// blab blab blab...
// end of manager.cpp
=================================
=================================
// file laborer.h
// class laborer defination
#include "employee.h"
class laborer: public employee{
// body here
};
------------------------------------
// file laborer.cpp
// implementation for class laborer.
#include "laborer.h"
// blab blab blab...
// end of laborer.cpp
=================================
=================================
// file driver.cpp
// testing and usage for classess
#include "laborer.h"
#include "manager.h"
int main() {
manage m1,m2;
laborer b1,m2;
// more go here for testing ...
return 0;
}
***************************************
***************************************
NOTE: I can NOT put everything in the one big file. My professor do NOT allow that. Class defination and implementation must be seperate. So there are total 7 files (2X3 class = 6, plus 1 for driver use for testing)
PROBLEM:
when I try to compile this problem, I get the following error
".. redefination of class employee .. "
As I can see, the driver.cpp includes "manager.h" and "laborer.h", and since both file "manager.h" and "laborer.h" include ( #include "employee.h" ) therefore it generate the error. Hence redefination of class employee.
So, how can I fix this problem? I'm using Dev-C++
Does compiler has anything to do with it? Since my professsor gonna use his own compiler to compile my program, so hopefully compiler will not be the problem.
Please help.. this is urgent..
Thank alot
If u can, please leave your AIM or Yahoo M.. so I can contact u .. just in case
There is a base class employee, and 2 others class (manager, laborer) which are derived from class employee.
=================================
=================================
// file employee.h
// class employee defination
class employee {
// body here
};
--------------------------
// file employee.cpp
// implementation for class employee.
#include "employee.h"
// blab blab blab...
// end of employee.cpp
=================================
=================================
// file manager.h
// class manager defination
#include "employee.h"
class manager : public employee{
// body here
};
------------------------------------
// file manager.cpp
// implementation for class manager.
#include "manager.h"
// blab blab blab...
// end of manager.cpp
=================================
=================================
// file laborer.h
// class laborer defination
#include "employee.h"
class laborer: public employee{
// body here
};
------------------------------------
// file laborer.cpp
// implementation for class laborer.
#include "laborer.h"
// blab blab blab...
// end of laborer.cpp
=================================
=================================
// file driver.cpp
// testing and usage for classess
#include "laborer.h"
#include "manager.h"
int main() {
manage m1,m2;
laborer b1,m2;
// more go here for testing ...
return 0;
}
***************************************
***************************************
NOTE: I can NOT put everything in the one big file. My professor do NOT allow that. Class defination and implementation must be seperate. So there are total 7 files (2X3 class = 6, plus 1 for driver use for testing)
PROBLEM:
when I try to compile this problem, I get the following error
".. redefination of class employee .. "
As I can see, the driver.cpp includes "manager.h" and "laborer.h", and since both file "manager.h" and "laborer.h" include ( #include "employee.h" ) therefore it generate the error. Hence redefination of class employee.
So, how can I fix this problem? I'm using Dev-C++
Does compiler has anything to do with it? Since my professsor gonna use his own compiler to compile my program, so hopefully compiler will not be the problem.
Please help.. this is urgent..
Thank alot
If u can, please leave your AIM or Yahoo M.. so I can contact u .. just in case