What is the best way to have some function in a tree or inherate class.

Here is what I have :
Code:
ClassA (who have the main)                     --
    |___ClassB (object 1)                             |----ClassD
                 |____ClassC (object 2)            --
And I want all to have ClassD but I do not want to include ClassD in all Class.