For Polymorphism, which technique is a perfect example in C++?1. Function / Operator Overloading2. Virtual Functions3. Template

Showing Answers 1 - 3 of 3 Answers

ravi_db

  • Feb 16th, 2007
 

All Technique are perfect.But when its need for Compile Time polymorphism then function/ Operator Overloading are used while when its run time polymorphism ,then Virtual function is used...the fact is that, as a Pure Virtual funcation ( Used for run time polymorphism) provide a foundation & concept of abstract Classes, makes it better than both above.

  Was this answer useful?  Yes

puneet83

  • Mar 30th, 2009
 

Polymorphism in C++ is broadly classified as :
1. Compile time Polymorphism eg. Operator/Funtion Overloading
2. Run time polymorphism eg. Virtual functions.

Compile time polymorphism is compartively faster that run time polymorphism. But Run time polymorphism provides more flexibility.

Thus, using either of two depends upon your requirement.



  Was this answer useful?  Yes

VENKATGOPU

  • Jun 10th, 2009
 

For Compile time polymorphism, Function/Operator overloading are good example

For Run time polymorphism, Virtual Function is good example.

  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