Original Post
I wrote code using inheritance, to avoid code-reuse. I just noticed this is not the purpose of inheritance...so I am wondering, WHAT IS the purpose of inheritance then? Also, how would I correctly structure my code, what classes and class connections should be made? I am writing my own little GUI system, where I have the following classes and inheritance (which is wrong I guess! this is just what I have now): - References (a reference count class, memory handling) - Signals derives from References (signal and slot system for events) - Container derives from Signals - Custom containers derive from container - Component derives from Signals - Custom component derive from component Each class needs References, to keep memory handled correctly. Then, both container and component need signals (prefered derived from! so one can use functions of signal as if it is a container/component function). The custom classes derive from their base classes and give functionality. Container and component need a virtual draw function which should be overwritten by the custom classes, however this is not possible (get a compiler error). Of a solution I thought of having instance of classes in the class instead to derive from them, would work for the reference class at least, not sure if it's a good idea for the signal class... How would one organise this code, where to use inheritance and where to use composition? Thanks!