Here you go. I had to attach the vehicle.h file to a vehicle.cpp file because of the rules for attachments. Anyway, it should be a .h file.
Printable View
Here you go. I had to attach the vehicle.h file to a vehicle.cpp file because of the rules for attachments. Anyway, it should be a .h file.
I took off the #endif and left it as the original.
> I took off the #endif and left it as the original.
But that's the whole point - you will get
.... unterminated '#if" conditional
If you don't have an #endif to match it.
Now put the #endif back in, recompile it, and IF you still get a problem, upload the file you most recently compiled with, and the error message you got.
Sampled history is no use.
I'll do that right now.
not for nothing but I did attempt to compile the program but it gave me the same error before and after I added the #endif. It will not complete run.
See the actual code below: (maybe I missing something and do apologize in advance) but I will also post the dev file itself, as well.
Thanks again.
Vehicle.h code:
/ header file - vehicle
#include<iostream.h>
#ifndef VEHICLE_H
#define VEHICLE_H
class vehicle //base class declaration
{
private:
int itsDoors;
int itsCylinders;
int itsEngineSize;
int itsWheels;
float wheelWeight;
};
void InputCarInfo (vehicle buildCar)
{
cout << "How many doors would you like.\n";
cin >> buildCar.itsDoors;
cout << "How many cylinders do you want\n";
cin >> buildCar.itsCylinders;
cout << "How many wheels do you need on the vehicle\n\n";
cin >> buildCar.itsWheels;
}
void DisplayCarInfo (vehicle yourCar)
{
cout << "The vehicle you built has " << yourCar.itsDoors << " doors, " << yourCar.itsCylinders << " cylinders, and " << yourCar.itsWheels << " wheels.\n";
}
#endif //This would be the latest code that still doesn't execute.
Your upload doesn't work, but I tested your last posted code in Dev C++ and adding an #endif removes the unterminated '#if" error, but your class is wrong.
In your functions you have attempted to access private data from the class. Unless these functions are members of the class they will not be able to access that information.
So you need to declare these functions as public members of your class. Alternatively you could make all yuour existing class data public, but I think that would defeat the point of what you are trying to do.
How did you get it to take out the error? I'm still getting the error when I compile the program. Could you please post what you did to the code? I would very much appreciate it.
Thanks for all your help. :)
I tried to compile it from the code you've posted a couple of posts up (the code that includes the #endif), the only thing I changed was one of your comments was missing a /.
Thanks again.