GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 156 of 203    Print  
polymorphism
what are the issue one should care implementing polymorphism.


  
Total Answers and Comments: 3 Last Update: April 16, 2008     Asked by: vikram_lok 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
January 07, 2008 07:02:44   #1  
Susil Kumar Member Since: January 2008   Contribution: 11    

RE: polymorphism
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

 
Is this answer useful? Yes | No
April 16, 2008 09:58:59   #2  
redleader Member Since: April 2008   Contribution: 10    

RE: polymorphism
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.



 
Is this answer useful? Yes | No
April 16, 2008 10:01:59   #3  
redleader Member Since: April 2008   Contribution: 10    

RE: polymorphism
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.


 
Is this answer useful? Yes | No


 
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