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:

    The quality of moral behaviour varies in inverse ratio to the number of human beings involved.
    Aldous Huxley (1894–1963)

    There is, I think, no point in the philosophy of progressive education which is sounder than its emphasis upon the importance of the participation of the learner in the formation of the purposes which direct his activities in the learning process, just as there is no defect in traditional education greater than its failure to secure the active cooperation of the pupil in construction of the purposes involved in his studying.
    John Dewey (1859–1952)

    In nothing was slavery so savage and relentless as in its attempted destruction of the family instincts of the Negro race in America. Individuals, not families; shelters, not homes; herding, not marriages, were the cardinal sins in that system of horrors.
    Fannie Barrier Williams (1855–1944)