Amazon Interview Question
A pure function in C++ is a member function of a class that is not implemented in that class. In C++ all pure functions must be declared as virtual. For this reason C++ programmers talk about pure virtual functions rather than abstract functions.
The concrete classes derived from the abstract class must overload all the pure functions and so define what the function does on objects in the derived class
An abstract class is a class that has one or more abstract operations[, i.e. pure function]. An abstract operation is not implemented in its [abstract] class but in classes that are derived from it.
Ref: http://www.csci.csusb.edu/dick/cs202/abstraction.html
In computer programming, a function may be described as pure if both these statements about the function hold:
The function always evaluates the same result value given the same argument value(s). The function result value cannot depend on any hidden information or state that may change as program execution proceeds or between different executions of the program, nor can it depend on any external input from I/O devices.
Evaluation of the result does not cause any semantically observable side effect or output, such as mutation of mutable objects or output to I/O devices.
Functions for which there are no side effects.
- Shailesh November 07, 2006