+ 2

What is a pure virtual function?

Pure virtual functions are virtual function with no definition. for example: virtual void func() =0;

26th Nov 2016, 2:15 AM
Shweta Pandey
Shweta Pandey - avatar
3 Respuestas
+ 1
A pure virtual function has no body and it's characterized by the =0 in its declaration. Such functions must be overridden in the derived class.
7th Jan 2017, 3:19 PM
Diego
Diego - avatar
0
Pure virtual functions are the virtual functions that are undefined in their base class and user of the base class define it in derived class as per the specifications of derived class.
26th Nov 2016, 3:11 AM
Gamer
Gamer - avatar
- 1
class Shape { protected: int width, height; public: Shape( int a=0, int b=0) { width = a; height = b; } // pure virtual function virtual int area() = 0; }; The = 0 tells the compiler that the function has no body and above virtual function will be called pure virtual function.
31st Dec 2016, 4:53 PM
Priyanshi
Priyanshi - avatar