CS Electrical And Electronics
@cselectricalandelectronics

Pure virtual functions in Cpp?

All QuestionsCategory: Cpp LanguagePure virtual functions in Cpp?
CS Electrical And Electronics Staff asked 4 years ago

I need short information.

1 Answers
CS Electrical And Electronics Staff answered 4 years ago
  1. A virtual function is declared inside the base class and it is redefined in the derived classes.
  2. The function inside the base class serves as a placeholder as it has no definition relative to the base class.
  3. Such functions are called “do-nothing” function
  4.              virtual void display() = 0;
  5. Such functions are called pure virtual functions.
  6. A class containing pure virtual functions cannot be used to declare any objects of its own, such classes are called abstract base classes.
  7. The main objective of an abstract base class is to provide some traits to the derived classes and to create a base pointer required for achieving run time polymorphism.