You can use macros to keep check of the files that might be redefined and thus you avoid the error altogether and do not need to make two separate projects. So, you will define your car.h file like this:
#ifndef CAR_H //This checks if the header file was defined
#define CAR_H //If it was not defined, it will define it
class Car
{
private:
int milage;
int passengers;
int model;
char* name;
public:
Car();
void setmilage(int);
int getmilage();
void setpassengers(int);
int getpassengers();
void setmodel(int);
int getmodel();
void setname(char* );
char* getname();
};
#endif /* CAR Seen */
No comments:
Post a Comment