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

MISTAKE:
1.returning a temp object so it goes out of scope.
2.using + for c-type strings.
SOLUTION:
string s = Add("SAM","SUNG");

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is protected inheritance?

1048


What do c++ programmers do?

1054


Can we inherit constructor in c++?

1091


Which is the best c++ compiler for beginners?

1092


Is python written in c or c++?

1140


What is a memory leak c++?

1136


What is a c++ vector?

1041


Is c++ a difficult language?

1120


What is c++ and its features?

1013


Should I learn c or c++ first?

1125


What is diamond problem in c++?

996


If a base class declares a function to be virtual, and a derived class does not use the term virtual when overriding that class, is it still virtual when inherited by a third-generation class?

1031


Why do you use the namespace feature?

1087


Explain the difference between c & c++?

1085


How a new operator differs from the operator new?

1117