C++ Programming - OOPS Concepts - Discussion

Discussion Forum : OOPS Concepts - General Questions (Q.No. 36)
36.
Which of the following is a mechanism of static polymorphism?
Operator overloading
Function overloading
Templates
All of the above
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
17 comments Page 1 of 2.

Nilay Vishwakarma said:   1 decade ago
This is static(compile time) polymorphism., same code for any type.

template<class XYZ>
XYZ large(XYZ a, XYZ b)
{
if(a>b)return a;
else return b;
return a;
}
int main()
{
string str1("Nilay"),str2("IndiaBIX")
cout<<large(10,20)<<"\n";
cout<<max(str1,str2);
return 0;
}

Mounika said:   9 years ago
If we define a function as a template function, it can work with different data types and if a class is made as a template, its members can be of any data type. Data types of members are given at the time of creating the object.

Aiman said:   4 years ago
Templates are a compile-time construct and type deduction is a process when the compiler automatically figures out the template arguments. This is where static polymorphism comes in.

Ashish said:   1 decade ago
I also have same doubt because template is a mechanism which is achieve through dynamic polymorphism.

Payal said:   1 decade ago
How can template mechanism of static polymorphism? please explain in brief.

Nikhil said:   8 years ago
I mean templates allso comes in static binding so all of the above.

Paras Santoki said:   1 decade ago
How Template achieve the static polymorphism can any explain?

Sushil Nirmale said:   7 years ago
I think Template comes under dynamic binding.
(1)

Lahari said:   6 years ago
To avoid the overloading we use templates.

Priya said:   1 decade ago
What is meant by static polymorphism?


Post your comments here:

Your comments will be displayed after verification.