![]() |
base type has incomplete type
Can someone please tell me why i get the error "base class has incomplete type"? I'm just learning my way through c++ so bear with me.
:
Next i'm learning virtual functions so i need to get this down first. Any help would be greatly appreaciated. If you need main() just let me know. Though I doupt it will help since main() isn't giving me the error, but one of the classes are. |
You haven't given enough information. My guess is that you have declared your classes in different header files, with a dependency between them. For example, you might have Vehicle.h which declares Vehicle, Boat.h which declares Boat. If Boat.h or Car.h do not #include "Vehicle.h" that might explain your error message.
You also need to #include <iostream> before any usage of std::cout. That might also account for your error. Unrelated to your problem, but both your derived classes have an int member named itsType. It may be appropriate, from a design perspective, for your base class to provide that member. Also, from a design perspective, it may be appropriate for your base class to provide some virtual methods that derived classes override, rather than having your derived classes introduce new characteristics. And, lastly, NEVER NEVER NEVER use comments of the form :
/////////////////////// |
1 Attachment(s)
Here's the simple project Hope this makes it more clear.
And please tell me if i've done everything properly. I'm using dev-C++. |
I just got bored and fed your code (from the first post) into a compiler.
It has a missing closing brace. Add one after the if/else clause for Vehicle::Speeding() function, and before the protected keyword. And refer to my previous post for what you need to do with Boat.h and Car.h that you have in your zip file. |
thx it was the closing brace
Thanks so much. I just wasn't able to see that.
It works now :D |
| All times are GMT -5. The time now is 12:34 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC