Polymorphism

What are the issue one should care implementing polymorphism.

Questions by vikram_lok

Showing Answers 1 - 9 of 9 Answers

The issues one shoul care about when implementing polymorphism in C++:

* C++ is not a purely object oriented programming language. On contrary, It supports all the possibilities in OOP.

* You can implement all the OOP concepts in C++

*What happens is that it allows operators such as new, delete to be overloaded. So when implementing overloadind operators in C++, You as a developer should be very careful.

* Do not have default parameters if you have one more function with the same number of parameters with same method signature.

*Do not unneccessarily define same function for different purposes.
                 Ex: Numeric class should not contain functions to concatenate two strings

  Was this answer useful?  Yes

redleader

  • Apr 16th, 2008
 

The question revolves around polymorphism, and not the general OOP compliance of the language.

Care should be taken in regards to early static binding, and late dynamic binding.

Object chopping or slicing,  when passing by value when passing by reference or pointer should be done.

Also during exception handling, again throwing an object, instead of reference or a pointer, which will result in the object being sliced.

There may be others, but these are the main issues.


  Was this answer useful?  Yes

redleader

  • Apr 16th, 2008
 

In regards to the point of static and dynamic binding, the virtual keyword needs to be used for any functions that need to be dynamically overriden and not statically overloaded.

  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