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:

    ... into the novel goes such taste as I have for rational behaviour and social portraiture. The short story, as I see it to be, allows for what is crazy about humanity: obstinacies, inordinate heroisms, “immortal longings.”
    Elizabeth Bowen (1899–1973)

    The construction of life is at present in the power of facts far more than convictions.
    Walter Benjamin (1892–1940)

    Fear not, we are of the nature of the lion, and cannot descend to the destruction of mice and such small beasts.
    Elizabeth I (1533–1603)