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

Can you write a function similar to printf()?

1097


What does it mean to declare a destructor as static?

1042


How do I run c++?

1021


Which field is used in c++?

1069


program explaining feautures of c++

2410


Differentiate between an external iterator and an internal iterator?

967


How delete [] is different from delete?

975


Who calls main function?

1071


What are the defining traits of an object-oriented language?

1160


Write about a nested class and mention its use?

1074


What should main() return in c and c++?

999


What is the purpose of ios::basefield in the following statement?

1221


What is runtime errors c++?

1079


How would you implement a substr() function that extracts a sub string from a given string?

1010


Write some differences between an external iterator and an internal iterator?

985