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 / prasad

i will provide error.

declare template function as,
T Add(T a, T b){return a+b ;}

Is This Answer Correct ?    10 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between global variables and local variable

540


What is tellg () in c++?

727


What is iostream in c++ used for?

553


How can a called function determine the number of arguments that have been passed to it?

662


What are the unique features of C++.

575






Write is a binary search tree? Write an algo and tell complexity?

598


Is c++ a high level language?

560


How does the copy constructor differ from the assignment operator (=)?

627


What is DlgProc?

604


Why do we use using namespace std in c++?

605


Where can I run c++ program?

605


What is c++ code?

591


What is the use of turbo c++?

554


What is a literal in c++?

569


What is an iterator?

690