Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What are pure virtual functions? Give a real-world example for abstract class and pure virtual function?

0
Posted

What are pure virtual functions? Give a real-world example for abstract class and pure virtual function?

0

A pure virtual function is a virtual function that doesn’t require a definition in the base class. A pure virtual function is defined by writing =0 after its signature. The definition can be provided if some default behavior or error-handling is required. In some cases it’s not logical to instantiate an object of a class. In such cases, the concept of abstract classes can be made use of. To make a class abstract, the class needs to include at least one pure virtual function. For Example: Consider a class Employee that defines the generic behavior of different types of Employees that work in a company.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123