Ok I think it works now.. debugging seems that the binary tree is built.
Now I have to implement a DFS to simulate circuit..
I have (Component*) head of tree, how to move along it?
I mean, I think that to obtain right output of circuit I have to start from the Leaves and do the logicFunction() for each of them.
Then, project asks for min and max path.. How to do this?
trees are usually moved along via recursion.
you pass in head. you want to go left or right
you recurse with the one you want, calling it as if head, and the recursed copy of the function operates on that sub-tree, repeat until done. traversing, you iterate all the pointers, so you basically have 3 operations … do something here, recurse left, recurse right (you can mix this order up as you see fit).
but when it's time to do: node->logicFunction(), it doesn't work because it does logicFunction() of class Component, instead of logicFunction of gates (&& if it's a and, || if a or..).
Why?
Just specify it... node->gates::logicfunction();
its caused by how you did your inheritance; whatever you did is finding the component version before the gates version in its search to resolve it.