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?
Discussion:
17 comments Page 2 of 2.
Qwe said:
1 decade ago
What is static polymorphism?
Priya said:
1 decade ago
What is meant by static polymorphism?
Akash said:
1 decade ago
Why Template?
Payal said:
1 decade ago
How can template mechanism of static polymorphism? please explain in brief.
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;
}
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;
}
Ashish said:
1 decade ago
I also have same doubt because template is a mechanism which is achieve through dynamic polymorphism.
Paras Santoki said:
1 decade ago
How Template achieve the static polymorphism can any explain?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers