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.
#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;
}
Comments
Leave a comment