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 guid? Why does com need guids?
Which compiler does turbo c++ use?
What is an incomplete type in c++?
What is different in C++, compare with unix?
What are the differences between the function prototype and the function defi-nition?
Are c and c++ different?
Snake Game: This is normal snake game which you can find in most of the mobiles. You can develop it in Java, C/C++, C# or what ever language you know.
what is a reference variable in C++?
Is rust better than c++?
write a porgram in c++ that reads an integer and print the biggest digit in the number
What is static class data?
What is the main use of c++?
Why is main an int?
A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a saleperson who sells $5000 worth of merchandise in a week receives $200 plus 9 percent of $5000, or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows: Item Value A 239.99 B 129.75 C 99.95 D 350.89 Write a program that inputs one salesperson's items sold in a week (how many of item A? of item B? etc.) and calculates and displays that salesperson's earnings for that week.
What's the most powerful programming language?