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

i will provide error.

declare template function as,
T Add(T a, T b){return a+b ;}

Is This Answer Correct ?    10 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is this pointer in c++?

734


Define stacks. Provide an example where they are useful.

579


Do you know the problem with overriding functions?

574


what are function pointers?

582


How do you declare A pointer to function which receives an int pointer and returns a float pointer

681






What is the difference between while and do while loop?

558


Are strings mutable in c++?

694


What are virtual functions in c++?

691


What is the difference between a reference and a pointer?

601


Is c++ map a hash table?

567


Explain method of creating object in C++ ?

597


A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a saleperson who sells $5000 worth of merchandise in a week receives $200 plus 9 percent of $5000, or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows: Item Value A 239.99 B 129.75 C 99.95 D 350.89 Write a program that inputs one salesperson's items sold in a week (how many of item A? of item B? etc.) and calculates and displays that salesperson's earnings for that week.

3413


Can we change the basic meaning of an operator in c++?

655


What are friend classes? What are advantages of using friend classes?

610


Assume an array of structure is in order by studentID field of the record, where student IDs go from 101 to 500. Write the most efficient pseudocode algorithm you can to find the record with a specific studentID if every single student ID from 101 to 500 is used and the array has 400 elements. Write the most efficient pseudocode algorithm you can to find a record with a studentID near the end of the IDs, say in the range from 450 to 500, if not every single student ID in the range of 101 to 500 is used and the array size is only 300

1791