Method (computer Science) - Virtual Methods

Virtual methods are the means by which a class object can achieve polymorphic behavior. Non-virtual methods, or regular methods, are those which do not participate in polymorphism.

C++ Example:

#include #include class Super { public: virtual void iAm { std::cout << "I'm the super class!\n"; } } class Sub : public Super { public: void iAm { std::cout << "I'm the subclass!\n"; } } int main { std::unique_ptr inst1(new Super); std::unique_ptr inst2(new Sub); inst1->iAm; // calls Super::iAm inst2->iAm; // calls Sub::iAm }

Read more about this topic:  Method (computer Science)

Famous quotes containing the words virtual and/or methods:

    Neither dead nor alive, the hostage is suspended by an incalculable outcome. It is not his destiny that awaits for him, nor his own death, but anonymous chance, which can only seem to him something absolutely arbitrary.... He is in a state of radical emergency, of virtual extermination.
    Jean Baudrillard (b. 1929)

    All men are equally proud. The only difference is that not all take the same methods of showing it.
    François, Duc De La Rochefoucauld (1613–1680)