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 is the basic of c++?
Can you please explain the difference between static and dynamic binding of functions?
How is computer programming useful in real life?
What is java and c++?
Which c++ compiler is best?
What are the various storage classes in C++?
How can you link a c++ program to c functions?
Why are pointers not used in c++?
Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.
Write about the retrieval of n number of objects during the process of delete[]p?
What is prototype in c++ with example?
Is java the same as c++?
Can you be bale to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?
What is the best c++ compiler?
Are there any special rules about inlining?