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

"SAM" and "SUNG" will be considered as const char * and
there will be an compile time error. To over come this we
can call the fun as

string c = Add<string>("SAM","SUNG");

as the string class as '+' operator overloaded and it will
add the two string.

Is This Answer Correct ?    15 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the differences between the function prototype and the function defi-nition?

1042


How we can differentiate between a pre and post increment operators during overloading?

1041


What is a .lib file in c++?

939


What are libraries in c++?

1016


What is lazy initialization in c++?

1048


Why is c++ awesome?

982


What is the difference between the functions memmove() and memcpy()?

1075


Explain method of creating object in C++ ?

1025


how to connect with oracle 9i with server in socket program in c/c++

2281


How would you use the functions randomize() and random()?

1021


How do you clear a map in c++?

1063


How is c++ different from java?

991


Why is swift so fast?

1055


What information can an exception contain?

1093


Is there a c++ certification?

988