Consider a c++ template funtion
template<class T>
T& Add(T a, T b){return a+b ;}
if this function is called as
T c = Add("SAM", "SUNG");
what will happen? What is the problem in the template
declaration/ How to solve the problem.
Answer Posted / sg
"SAM" and "SUNG" will be considered as const char * and
there will be an compile time error. To over come this we
can call the fun as
string c = Add<string>("SAM","SUNG");
as the string class as '+' operator overloaded and it will
add the two string.
| Is This Answer Correct ? | 15 Yes | 1 No |
Post New Answer View All Answers
What are activex and ole?
Why do we use double in c++?
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create
Can you please explain the difference between overloading and overriding?
Where do I find the current c or c++ standard documents?
Why is c++ considered difficult?
What does scope resolution operator do?
What is ifstream c++?
Difference between overloading vs. Overriding
Explain the difference between using macro and inline functions?
Do the parentheses after the type name make a difference with new?
Can a constructor return a value?
Write about the members that a derived class can add?
When does a 'this' pointer get created?
Can a program run without main?