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 = 2, ii;
string ww("A");
ii = square<int>(i);
cout << i << ": " << ii;
cout << square<string>(ww) << ":" << endl;
}
a.
2:4AA
b.
2:4
c.
AA
d.
2:4A
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 specialization are there in c++?
View solution
Q. What is other name of full specialization?
View solution
Q. Which is dependant on template parameter?
View solution
Q. Which value is placed in the base class?
View solution
Q. How many bits of memory needed for internal representation of class?
View solution
Q. How many kinds of entities are directly parameterized in c++?
View solution
Q. How many kinds of parameters are there in C++?
View solution
Q. Which keyword is used to handle the expection?
View solution
Q. Which is used to throw a exception?
View solution
Q. What is the use of the ‘finally’ keyword?
View solution
Q. How do define the user-defined exceptions?
View solution
Q. Which exception is thrown by dynamic_cast?
View solution
Q. How many types of exception handling are there in c++?
View solution
Q. How many runtime error messages associated with exception?
View solution
Q. Which block should be placed after try block?
View solution
Q. Pick out the correct Answer:
View solution
Q. When exceptions are used?
View solution
Q. How many parameters does the throw expression can have?
View solution
Q. Where exception are handled?
View solution
Q. Which is used to check the error in the block?
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!