求助大神,一道题简单的题希望帮忙改改

6-3 函数重载实现两数相加 (15分)

设计一个重载函数add,该函数有两个参数,可以实现两个类型相同的参数相加的操作,函数返回相加的结果。两个参数可以是整数、实数和字符串,但必须保证两个参数类型相同。
裁判测试程序样例:
#include
#include
#include
using namespace std;

/* 请在这里填写答案 */

int main()
{
int a, b;
double c, d;
string s1, s2;

cin >> a >> b;
cin >> c >> d;
cin >> s1 >> s2;

cout << add(a, b) << endl;
cout << fixed << setprecision(2) << add(c, d) << endl;
cout << add(s1, s2) << endl;

输入样例:
3 5
3.3333 5.555555
hello world
输出样例:
8
8.89
helloworld
字符串的add函数不大懂
char add(char *s1,char *s2)
{
return strcat(s1,s2);
}

strcat(s1,s2);

将s2和s1连起来,结果放在s1里面

所以应该是
char* add(char *s1,char *s2)
{
strcat(s1,s2);
return s1;
}
就你题目来说,应该写

#include <string>
int add(int a, int b)
{
return a + b;
}
double add(double a, double b)
{
return a + b;
}
string add(string a, string b)
{
return a + b;
}

另外,https://ask.csdn.net/questions/1056674 这个问题请采纳一下。