Virtual Function - Behaviour During Construction and Destruction

Behaviour During Construction and Destruction

Languages differ in their behaviour while the constructor or destructor of an object is running. For some languages, notably C++, the virtual dispatching mechanism has different semantics during construction and destruction of an object. While it is recommended that virtual function calls in constructors should be avoided for C++, in some other languages, for example C# and Java, the derived implementation can be called during construction and design patterns such as the Abstract Factory Pattern actively promote this usage in languages supporting the ability.

Read more about this topic:  Virtual Function

Famous quotes containing the words behaviour, construction and/or destruction:

    I cannot be much pleased without an appearance of truth; at least of possibility—I wish the history to be natural though the sentiments are refined; and the characters to be probable, though their behaviour is excelling.
    Frances Burney (1752–1840)

    There’s no art
    To find the mind’s construction in the face.
    William Shakespeare (1564–1616)

    The true gardener then brushes over the ground with slow and gentle hand, to liberate a space for breath round some favourite; but he is not thinking about destruction except incidentally. It is only the amateur like myself who becomes obsessed and rejoices with a sadistic pleasure in weeds that are big and bad enough to pull, and at last, almost forgetting the flowers altogether, turns into a Reformer.
    Freya Stark (1893–1993)