Answer» Class.hpp:
Code: [SELECT]class Car { public: Car(long); ~Car() {} start_park(); DRIVE(); reverse(); private: unsigned int mileMarker; bool on_off; }
Errors in Compile:
Code: [Select]"Class.hpp": E2176 Too many types in declaration at line 1 "Class.hpp": E2238 Multiple declaration for 'Car' at line 2 "Class.hpp": E2344 Earlier declaration of 'Car' at line 1 I KNOW zilch about C++ programming but I'll give this a try just for fun.
I think the Car(long) statement is in conflict with the class declaration.
Sorry I couldn't be more help. :-/
Well, that's a constructor, but I'll remove the long and try it.New errors:
Code: [Select] bcc32 -D_DEBUG -g100 -j25 -Od -r- -k -y -v -vi- -TWC -c -IC:\CBuilderX\include -o"C:\Documents and Settings\Tom\cbproject\Car Simulator\windows\Debug_Build\Simulator.obj" Simulator.cpp Borland C++ 5.6.4 for Win32 Copyright (c) 1993, 2002 Borland Simulator.cpp: "Functions.hpp": E2379 Statement missing ; in function Car::startPark() at line 14 "Functions.hpp": E2379 Statement missing ; in function Car::startPark() at line 19 "Functions.hpp": E2379 Statement missing ; in function Car::startPark() at line 20 "Functions.hpp": E2379 Statement missing ; in function Car::drive() at line 29 "Functions.hpp": E2379 Statement missing ; in function Car::drive() at line 30 "Functions.hpp": E2379 Statement missing ; in function Car::drive() at line 34 "Functions.hpp": E2379 Statement missing ; in function Car::drive() at line 36 "Functions.hpp": E2379 Statement missing ; in function Car::reverse() at line 44 "Functions.hpp": E2379 Statement missing ; in function Car::reverse() at line 45 "Functions.hpp": E2379 Statement missing ; in function Car::reverse() at line 49 "Functions.hpp": E2379 Statement missing ; in function Car::reverse() at line 51 "Functions.hpp": E2379 Statement missing ; in function Car::sim() at line 59 "Functions.hpp": E2379 Statement missing ; in function Car::sim() at line 60 "Functions.hpp": E2379 Statement missing ; in function Car::sim() at line 64 "Functions.hpp": W8070 Function should return a value in function Car::sim() at line 86 "Simulator.cpp": E2379 Statement missing ; in function main() at line 8 "Simulator.cpp": E2379 Statement missing ; in function main() at line 9 *** 16 errors in Compile *** BCC32 exited with error code: 1 Build cancelled due to errors
Here's the whole program:
Code: [Select]
Class.hpp:
class Car { public: Car(unsigned long); ~Car() {} drive(); reverse(); sim(); startPark(); private: unsigned int mileMarker; bool on_off; };
Functions.hpp:
#include <iostream> #include <C:/Documents and Settings/Tom/cbproject/Car Simulator/Class.hpp>
Car::Car(unsigned long startingPoint) { mileMarker = startingPoint; };
Car::startPark() { if (on_off) { on_off = 0; std::cout "The car is now off.\n"; } else { on_off = 1; std::cout "VROOM!!! VROOM!!!" std::endl; std::cout "The car is now on." std:endl; } return 0; };
Car::drive() { unsigned int distance;
std::cout "How far will you drive?\t"; std::cin distance std::endl;
for (unsigned int counter = 0; counter < distance; counter++) { std::cout "Now passing mile marker " mileMarker++ "." std::endl; } std::cout "Now at mile marker " mileMarker "." std::endl; return 0; };
Car::reverse() { unsigned int distance;
std::cout "How far back will you go?\t"; std::cin distance std::endl;
for (unsigned int counter = 0; counter < distance; counter++) { std::cout "Now passing mile marker " milemarker-- "." std endl; } std::cout "Now at mile marker " mileMarker "." std::endl; return 0; };
Car::sim() { Car theCar(NULL);
std::cout "Start car? 0-Yes 1-No\t"; std::cin on_off std::endl;
theCar.startPark()
if (on_off) { short int whatToDo;
std::cout "What do you want to do?\n"; std::cout "0-Park 1-Drive 2-Reverse\n"; std::cin whatToDo std::endl;
switch (whatToDo) { case 0: theCar.startPark(on_off); break; case 1: theCar.drive(); break; case 2: theCar.reverse(); break; default: std::cout "Please choose one of the VALID choices..."; break; } break; } return 0; };
Simulator.cpp:
#include <iostream> #include <C:/Documents and Settings/Tom/cbproject/Car Simulator/Functions.hpp>
int main() { unsigned long startingMileMarker;
std::cout "What mile marker do you want to start at?\t" std::endl; std::cin startingMileMarker std::endl;
Car theCar(startingMileMarker);
theCar.sim(); };
(P.S.) I know it's a bad programming PRACTICE to use directories with " " in them, but I'll be changing that soon. Anyways, that isn't causing my problem...Nevermind. I figured it out.
|