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 is the basic of c++?

1105


Can you please explain the difference between static and dynamic binding of functions?

1070


How is computer programming useful in real life?

1114


What is java and c++?

1226


Which c++ compiler is best?

1202


What are the various storage classes in C++?

1184


How can you link a c++ program to c functions?

1138


Why are pointers not used in c++?

1189


Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.

1090


Write about the retrieval of n number of objects during the process of delete[]p?

1061


What is prototype in c++ with example?

1229


Is java the same as c++?

1035


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

1046


What is the best c++ compiler?

1221


Are there any special rules about inlining?

1129