Does this design represent circular dependency?

Imagine this example (that may be run without any errors): from random import uniform class Car: def __init__(self, position): self.position = position self.sensor = Sensor(id, self) class Sensor: def __init__(self, id, carrier_car): self.id = id self.position = self.compute_position(carrier_car) def compute_position(self, carrier_car): return [carrier_car.position[0] + uniform(1,3), carrier_car.position[0] + uniform(2,4)] car1 = Car([10,10]) print("This car’s sensor coordinate… Read More Does this design represent circular dependency?

Why isn't this abstract class working with circular dependency?

When I compile my code, i get: "src/gameObject.cpp:8:13: error: expected unqualified-id before ‘class’ GameObject::class Component& getComponent(const std::string &name)" alongside several other errors of a similar type. I’m not sure if the problem has to do with the abstract class, or the forward declaration of the class. I have tried troubleshooting for the past day and… Read More Why isn't this abstract class working with circular dependency?

Resolving apparent circular dependency: class A having a method that takes in class B, while class B having a member of type class A

I have two classes that I want to define, Position and TangentVector, partially given as follows: class Position { public: Position(double x, double y, double z); // getters double x(){ return m_x }; double y(){ return m_x }; double z(){ return m_x }; void translate(const TangentVector& tangent_vector); private: double m_x; double m_y; double m_z; }… Read More Resolving apparent circular dependency: class A having a method that takes in class B, while class B having a member of type class A