Question
#include <iostream>
using namespace std;
template <class T>
inline T square(T x)
{
T result;
result = x * x;
return result;
};
template <>
string square<string>(string ss)
{
return (ss+ss);
};
int main()
{
int i = 4, ii;
string ww("A");
ii = square<int>(i);
cout << i << ii;
cout << square<string>(ww) << endl;
}
a.
416AA
b.
164AA
c.
AA416
d.
none of the mentioned
Posted under Object Oriented Programming Using C++
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What is the output of this program?
Similar Questions
Discover Related MCQs
Q. How many types of templates are there in c++?
View solution
Q. Which are done by compiler for templates?
View solution
Q. What may be the name of the parameter that the template should take?
View solution
Q. How many parameters are legal for non-type template?
View solution
Q. What is a function template?
View solution
Q. Which is used to describe the function using placeholder types?
View solution
Q. Pick out the correct statement.
View solution
Q. What can be passed by non-type template parameters during compile time?
View solution
Q. From where does the template class derived?
View solution
Q. What is meant by template parameter?
View solution
Q. Which keyword can be used in template?
View solution
Q. What is the validity of template parameters?
View solution
Q. Why we use :: template-template parameter?
View solution
Q. Which parameter is legal for non-type template?
View solution
Q. Which of the things does not require instantiation?
View solution
Q. What is meant by template specialization?
View solution
Q. Which is similar to template specialization?
View solution
Q. Which is called on allocating the memory for array of objects?
View solution
Q. How many types of specialization are there in c++?
View solution
Q. What is other name of full specialization?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Object Oriented Programming Using C++? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!