What are the different forms of polymorphism??
Answers were Sorted based on User's Feedback
Answer / suganyamuralidharan
1.Compile time polymorphism
Exhibited by: Function overloading
Operator overloading
2.Run time polymorphism
Exhibited by: Function overriding
Is This Answer Correct ? | 22 Yes | 3 No |
Answer / sriram
A.) Runtime POLYMORPHISM
B.) Compiletime POLYMORPHISMS.,
Is This Answer Correct ? | 12 Yes | 2 No |
Answer / purba phalguni mishra
(1). Operator overloading.
(2). Function overloading.
(3). Virtual functions
Is This Answer Correct ? | 11 Yes | 3 No |
Answer / amit
1.Compile time polymorphism
Exhibited by: Function overloading
Operator overloading
2.Run time polymorphism
Exhibited by: Function overriding
Is This Answer Correct ? | 8 Yes | 2 No |
Answer / amit
There are two types of polymorphism:-
1.Compile time polymorphism
This is achieved by:
- Function overloading
- Operator overloading
2.Run time polymorphism
This is achieved through inheritance and virtual functions.
In this, base class has one or more virtual functions which
are overridden in the derived class. And then base class
pointer is used to access base or derived class virtual
function.
Example:-
class base {
public:
virtual void func() {
cout << "In base class" << endl;
}
};
class derived {
public:
void func() {
cout << "In derived class" << endl;
}
};
int main(){
base *bp, b;
derived d;
bp = &b;
bp->func(); // base class func() will be called
bp = &d;
bp->func(); // derived class func() will be called
return 0;
}
Here, the decision to call base or derived class func() is
taken at run time.
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / mms zubeir
Though there are many answers which are all true to some
extent, I would like to conclude all these into two broad
categories:
1. Ad-hoc polymorphism
2. Parametric polymorphism
As the meaning of the names themselves suggests their usage.
If the range of actual types that can be used is finite
and the combinations must be specified individually prior
to use, it is called Ad-hoc polymorphism.
If all code is written without mention of any specific type
and thus can be used transparently with any number of new
types, it is called parametric polymorphism.
Is This Answer Correct ? | 5 Yes | 3 No |
Answer / ramesh
1.Compile time polymorphism
Exhibited by: Function overloading
Operator overloading
2.Run time polymorphism
Exhibited by: Function overriding
Is This Answer Correct ? | 0 Yes | 0 No |
What is polymorphism in oops?
What is polymorphism explain its types?
Differences between inline functions and non-inline functions?
What is object-oriented programming? Webopedia definition
WAP find square root of any number (without using sqrt() )?
why in java first invoke public static void main(String args[]) method????Why not public static void method1(String args[])??
assume the program must insert 4 elements from the key board and then do the following programs.sequential search(search one of the elements),using insertion sort(sort the element) and using selection sort(sort the element).
What is abstraction encapsulation?
What is meant by oops concept?
how does a main() in C++ is different from main() in C?
What is namespace?
class CTest { public: void someMethod() { int nCount = 0; cout << "This is some method --> " << nCount; } }; int main() { CTest *pctest; pctest->someMethod(); return 0; } It will executes the someMethod() and displays the value too. how is it possible with our creating memory for the class . i think iam not creating object for the class. Thanks in Advance... Prakash