I have a treatment parent class, and two children, inner treatment and outer treatment. I need to create a single linked list that contains both of the children nodes. I'm not allowed to use templates, or built in lists.
The problem I'm facing is the type of the next
ptr, the only solution I found is to create a base node parent type, and put the two children inside it, plus a type variable to know which kind of node it is. Something like this:
enum node_type = {inner, outer};
struct treatment_node{
Inner_Treatment t1;
Outer_treatment t2;
struct treatment_node *next;
node_type treatment_type;
}
I'll know which class to access based on the treatment type. Would this work?