PDA

Click to See Complete Forum and Search --> : Error C2504???


Dillinger4
Jun 25th, 2000, 07:22 AM
Im making {or trying to make} a car simulator in C++
It is a console application, but i keep getting this error
C2504. Undefined base class.

#include "Odometer.h"


//this is the base class

class Car
{
public:
// class constructor to initilize objects as they are created
// and to ensure that data members contain vaild values
Car(bool B = false, bool A = false)
{
m_brake(B);
m_accelerator(A);
}



void set_temp(); // member functions prototype
void start_engine();
void kill_engine();
void set_gas();
void set_brake();
void change_gears();
void change_direction();

int get_speed();
int get_fuel();
int get_distance();
int get_RPM();
int get_temp();

char m_brake; // data members
char m_accelerator;
};

// derived class in another file

// class defination for our odometer


class Odometer: public Car
{ // error is generated here when compiled Do i have to
public: // use the extern keyword to specify external
// linkage ?????? That's the only thing i can
// think of


Odometer(long dt = 0) // class constructor
{
m_distance_trav(dt);
}

int reading(int cur_speed); //function prototype



long m_distance_trav;
};


// thanks all!!!














};

parksie
Jun 26th, 2000, 01:37 AM
where your error was, did you have a space between "Odometer" and the colon? -


Odometer : public Car

rather than

Odometer: public Car


I think it's compiler dependent, but you seem to be using MSVC++.

If you have your Car class defined in Car.h, with the implementation in Car.cpp, then put Odometer in Odometer.h, with it's implementation in Odometer.cpp. Then, in Odometer.h, #include "Car.h". this should solve your problem.