I have a C++ architectural design problem. I am trying to work on a circuit simulator where I have defined 3 classes. A node class, component class, and circuit class. Here is a simplified layout of those classes
https://gist.github.com/Nick0412/0b9a0ba8848cb5225d5bd663dad8fd77
Now my impression is that when I create a specific component, say resistor, it will inherit from the component class. However when I add an arbitrary component to the circuit, I want the circuit to do specific things depending on what kind of component is added.
So I have two questions. First, would a visitor type pattern be the most appropriate way to solve this? Second, does anyone have any feedback on if this layout is reasonable?
Aucun commentaire:
Enregistrer un commentaire