+ 6
What is the pure virtual definition in C++
2 Respuestas
+ 9
In a class/interface definition, a pure virtual function is one that doesn't have any definition (doesn't have any statements). The pure virtual functions must be implemented (and this is mandatory) in the subclasses in order to the subclasses to compile.
The idea is to leave a blueprint of what the subclasses of a particular class/interface should implemented to have a common functionality between all the impplementations.
The syntax is as follows:
virtual return_type function_name(args) = 0;
where return_type if the data type to be returned (void if it has no return), function_name is the name of you function and args the list of arguments if apply.
+ 6
Thank you for detailed answer!