GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 141 of 203    Print  
What are Polymorphic Classes?

  
Total Answers and Comments: 3 Last Update: April 09, 2009     Asked by: Karun 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Niranjan.ambati
 

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



Above answer was rated as good by the following members:
es1968
July 20, 2007 02:30:52   #1  
Samit Katiyar        

RE: What are Polymorphic Classes?
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.

 
Is this answer useful? Yes | No
December 07, 2008 10:13:18   #2  
burraganesh Member Since: December 2008   Contribution: 20    

RE: What are Polymorphic Classes?
A template class is nothing but a polymorphic class because it can work with different data-types also under one name.
 
Is this answer useful? Yes | No
April 09, 2009 06:58:23   #3  
Niranjan.ambati Member Since: April 2009   Contribution: 4    

RE: What are Polymorphic Classes?

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


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape