Few days ago a person asked me a question that "How can achieve polymorphism without using overloading and overriding?".
I answered him that "it can be achieved by interface " but he again asked me interface is not part of oops programming it is a part of c# language so How will you achieve it in other language Like:
C++;
I don't know without overloading and overriding how it is possible.
So anyone can give me a answer if there is another method of Polymorphism.
thanks.........
Loading

Gowtham RajamanickamPosted Apr 5, 2015, 11:26 PM
Pankaj Kumar ChoudharyPosted Mar 22, 2015, 8:43 AM
Thanks for your answer.
VulpesPosted Mar 22, 2015, 6:28 AM
These give you what is sometimes called 'parametric polymorphism' in that the members of the class will behave differently, albeit to the same pattern, depending on the type parameter(s) passed to the template.
We do, of course, have a similar concept in C# with generics.
Pankaj Kumar ChoudharyPosted Mar 22, 2015, 4:06 AM
if in future you find the answer of this question then please doesn't forget to tell me the answer....
Thanks................
Abhishek JaiswalPosted Mar 22, 2015, 3:24 AM
Now i got the complete scenario of ur question. That's really interesting.
In different object oriented languages there are diff ways of achieving a particular functionality for example in C++, as i suggested. But if we talk about a general scenario or mechanism to achieve a particular functionality in all the same type of languages then its quite complex i think.
So, I don't think there is any general method that can work for all the languages (for ex). Meanwhile if you found any then don't forget to post it.
:)
Pankaj Kumar ChoudharyPosted Mar 22, 2015, 2:48 AM
Overriding is an object-oriented programming feature that enables a child class to provide different implementation for a method that is already defined and/or implemented in its parent class or one of its parent classes. The overriden method in the child class should have the same name, signature, and parameters as the one in its parent class. So overriding is achieved by Inheritance.
So overriding is achieved by inheritance .
So inheritance is not a other concept of achieving polymorphism(it is already use in method overriding).
I am asking for another method remaining overloading and overriding(inheritance).
I want to say that if we use inheritance of polymorphism then this concept is known as overriding.
If i am wrong then you can explain how can i achieve polymorphism using inheritance(without overriding)....
Abhishek JaiswalPosted Mar 22, 2015, 2:16 AM
I mean if u waana achieve polymorphism (using OOPs) without using overloading and overriding then u can use inheritance. As Inheritance is also one of the pillars of OOps.
If we talk about other object oriented languages like C++, it uses a member function to achieve that functionality.
IN C++ a member function will cause a different function to be executed depending upon the type of the object that invokes the particular function.
I hope now, u will get a theme. :)
Pankaj Kumar ChoudharyPosted Mar 22, 2015, 2:08 AM
Please you can elaborate your answer................
Abhishek JaiswalPosted Mar 22, 2015, 1:56 AM
That's a very good question. I think we can always do that using inheritance.
I hope, this could help.