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
give me an example for testing a program showing the test path .show how the test is important and complex.
What is encapsulation in C++? Give an example.
What are destructors?
What is flush () in c++?
What are the rules for naming an identifier?
what is Loop function? What are different types of Loops?
In which header file does one find isalpha() a) conio.h b) stdio.h c) ctype.h
Can char be a number c++?
Why would you use pointers in c++?
Who invented turbo c++?
Explain 'this' pointer and what would happen if a pointer is deleted twice?
Write a program which is required to process the time of a clock in hours and minutes, entered from the keyboard. With this program, there are two requirements for any data entered by a user: 1. The data must be of the correct type (in this case, two ints). 2. The data must be in the correct range: this means that, for the minutes, negative numbers and any number above 59 must be rejected; for the hours, negative numbers and any number above 23 must be rejected. Output error message for invalid data input. Output the time one and a half hour after the time input. i.e. Hour: 22 Min: 32 One and a half hour after 22:32 is 00:02
Which programming language should I learn first?
Why do we need c++?
Explain the isa and hasa class relationships.