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:

    “When we read of human beings behaving in certain ways, with the approval of the author, who gives his benediction to this behaviour by his attitude towards the result of the behaviour arranged by himself, we can be influenced towards behaving in the same way.”
    —T.S. (Thomas Stearns)

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

    “If only nature is real and if, in nature, only desire and destruction are legitimate, then, in that all humanity does not suffice to assuage the thirst for blood, the path of destruction must lead to universal annihilation.”
    —Albert Camus (1913–1960)