I have created a linked list in Java, and now I am trying to convert my program to C++.
When I try to compile, it gives me the error saying that 'next' uses 'CarNode' which is being defined. I am wondering if there is any way around this?
Java:
public class CarNode {
public Car carObject;
public CarNode next;
public CarNode (Car newCar, CarNode newNext) {
carObject = newCar;
next = newNext;
}
}
C++:
class CarNode: public Car {
public:
Car carObject;
CarNode next;
CarNode(Car newCar, CarNode newNext) {
carObject = newCar;
next = newNext;
}
}