Answer to Question #272293 in C++ for gikovi

Question #272293

Write a function template to add two numbers. Overload the function template to add three numbers. The third template argument should have the default value as <int> . When the function is called with char type of arguments, the characters should be concatenated to form a string.


1
Expert's answer
2021-11-27T11:34:34-0500
#include <iostream>
using namespace std; 
void add(int i, int b, int c) {
  cout << "Sum of 3 intergers " << i +b+c<< endl;
}
void add(double  f,double n) {
  cout << "sum of 3 float numbers is " << f+n << endl;
}
void add(char const *c, char const *d) {
  cout << "concatenation of characters char* " << c<<d<< endl;
}
 
int main() {
  add(10,11,5);
  add(10.10,10.4,5.5);
  add("ten","sum");
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS