What are Polymorphic Classes?

Showing Answers 1 - 12 of 12 Answers

Samit Katiyar

  • Jul 20th, 2007
 

A class that declares or inherits a virtual function is called a polymorphic class.

The main difference between an abstract base class and a polymorphic class is that because in abstract base classes at least one of its members lacks implementation we cannot create instances (objects) of it.

  Was this answer useful?  Yes

Polymorphic means many forms. The object of the polymorphic class pointer can store any derived class objects and called respective member functions when its object member functions is called automatically instead of calling base class member function.

By using "Virtual" key word in front of Base class member function, the base class become polymorphic class. when this member function assigns = 0 then it becomes pure virtual function and Base class become Abstract class.

The advantage of polymorphic class are

1. Late binding (run time)

2. It acts as interface between implementation and calling class.
3. The polymorphic class pointer can be assigned with array of derived class objects and called respective member functions.
4. Encapsulation can be achieved in the form of API (actual implementation).

Hope this explanation helps you.

Regards,
Niranjan Ambati

Khansnaina

  • Sep 20th, 2019
 

I want implications of polymorphic use of classes

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions