In [[object-oriented programming]], a '''pure virtual function''' or '''pure virtual method''' is a [[virtual methodfunction]] whichthat has a [[declaration]] (a signature), but no definition (implementation). This may be used where it does not make sense to provide a default implementation of a [[method (computer science)|method]].
In [[C Plus Plus|C++]], pure virtual methodsfunctions only make sense (and are only legal) in an [[inheritance tree]]. Classes whichthat have one or more pure virtual methodsfunctions cannot be instantiated. This is because the compiler would not have any code to execute if the user of the class tried to call a pure virtual methodfunction. Thus, in C++, pure virtual methodsfunctions force deriving classes to implement a piece of functionality to fulfil the pure virtual methodfunction.
A real world example may be a class of type account. The designer may decidedeem it to be undesirable to provide a default implementation of a '"Calculate Interest'" method, instead leaving the actual implementation to the designers of the derived classes '"Current Account'" and '"Savings Account'."▼
▲A real world example may be a class of type account. The designer may decide it to be undesirable to provide a default implementation of a 'Calculate Interest' method, instead leaving the actual implementation to the designers of the derived classes 'Current Account' and 'Savings Account'.