Languages Features Calendar About Lists Add Language
GitHub icon

Virtual function

Virtual function

Virtual function is a language feature.

A virtual function defines a target function to be executed, but the target might not be known at compile time.

Languages with Virtual function include C++

Example from C++:

class Animal { public: // Intentionally not virtual: void Move(void) { std::cout << "This animal moves in some way" << std::endl; } virtual void Eat(void) = 0; }; // The class "Animal" may possess a definition for Eat if desired. class Llama : public Animal { public: // The non virtual function Move is inherited but not overridden. void Eat(void) override { std::cout << "Llamas eat grass!" << std::endl; } };

Article source

PLDB - Build the next great programming language. v5.0.0 - Acknowledgements · Email · GitHub