Whats up guys ,
I have to design a a motorbike class today using inheritance from a vehicle class that i had previously designed. My goals are
1) to design a vehicle class with speed and turn rate - DONE
2) From this basic class design a motorbike with Speed (Inherited from motor class) and Type of bike (Char type)
im having trouble with building however as i keep getting errors in my Vehicle. h file , this was running perfectly before i modified the .cpp file and added in a another header file
From a quick scan, I can see two problems. First - BikeType should be a const char*, not a char - one is a string, the other is a letter.
The other one is multiple inclusion. Indirectly, in you cpp file, Vehicle.h is included twice. The easiest way to fix this is to put what is called 'header guards' for your header files, specifically to stop this problem. Here is how you would do it (do this for every header file):
1 2 3 4 5 6
#ifndef __HEADERNAME_H_INCLUDED__
#define __HEADERNAME_H_INCLUDED__
// contents of header
#endif
Replace 'headername' with the name of the header - each file should have a unique name. The format of the name can be different, but that is the way I normally use.
Also, on a side note, you haven't actually used inheritance with your motorbike class. Take another look at its definition - whats missing?