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

Distinguish between new and malloc and delete and free().

953


What are the operators in c++?

1055


How much do c++ programmers make?

1053


What is the most useful programming language?

994


What is an overflow error?

1045


What do you mean by public protected and private in c++?

997


Using a smart pointer can we iterate through a container?

1021


What are the advantage of using register variables?

1110


Define copy constructor.

1056


What is oop in c++?

1028


Can you be able to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?

1045


What are c++ manipulators?

1004


What is this pointer in c++?

1306


Why do we need function?

997


Explain the concept of friend function in c++?

1049