I've never used or needed inheritance for any of the code I have written. My understanding of best practices is that inheritance is rarely used/needed in most coding applications. I have come across a use-case where I think inheritance might make sense, and I'm wanting help evaluating if this is a correct place to use inheritance.
I'm storing each node of the branch and bound algorithm as an object. The root node is constructed using one algorithm, and left and right nodes are constructed from the previous node using a different algorithm.
class Node {
public:
int bound();
Node left();
Node right();
Node() = delete;
// more stuff
};
class Root : public Node {
Root(T m);
// maybe more stuff, maybe not
};
In this case, the Root node isn't very special. The only reason to define it is to make it clear that most Nodes aren't constructed from Ts. Writing the code is not easier with inheritance.
Is this an appropriate place to use inheritance? What other considerations should I make before using inheritance here?