Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / tathagata chakraborty

None of the other answers are coming to the point of this
question.They r all wrong.

right answer is the code will crash while returning frm Add
(). bcause the function is returning a local variable of
type T i.e. a+b as a refference. u cannont return a local
variable as refference bcause that will go out of scope as
soon as the function returns.

Is This Answer Correct ?    11 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is main a class in c++?

960


Is C++ case sensitive a) False b) Depends on implementation c) True

1014


What is object file? How can you access object file?

1117


What's the best free c++ profiler for windows?

1031


Which recursive sorting technique always makes recursive calls to sort subarrays that are about half size of the original array?

945


How can we access protected and private members of a class?

1051


How do you flush a buffer in c++?

1053


What is the use of dot in c++?

1023


What is the last index number in an array of 100 characters a) 100 b) 99 c) 101

1089


What is the copy-and-swap idiom?

1042


What do you mean by stack unwinding in c++?

1172


Is c++ double?

976


What would happen on forgetting [], while deallocating an array through new?

1024


Explain the isa and hasa class relationships. How would you implement each?

1061


What are the uses of pointers?

1020