I have Road and Car classes that are in their own .cpp and .h files. I include the .h file for the Road class in the Car header. I am using the Road class as a parameter for functions in the Car classes. I have static variables in the car class I need access to in the road class.
The compiler is not recognizing the Road type in the Car Class, and I can't figure out why.
Road.h
#ifndef ROAD_H
#define ROAD_H
#include <iostream>
#include "car.h"
using namespace std;
class Road
{
public:
// class functions
private:
// member variables
};
#endif
Car.h
#ifndef CAR_H
#define CAR_H
#include <iostream>
#include "road.h"
using namespace std;
class Car
{
public:
// class functions
void enter_a_road(Road& r1, const short left_pos);
private:
// member variables
};
#endif
Error Message:
In file included from Road.h:11:0,
from Road.cpp:6:
Car.h:68:23: error: 'Road' has not been declared
void enter_a_road(Road& r1, const short left_pos);
^