Description
写出3组Plus函数的声明与实现,类型分别为int,double,string
Sample Input
1
2 3
2.5 3.5
women day
Sample Output
5
6
womenday
Provided Codes
overload.cpp
#include<iostream>
#include"overlode.h"
int main() {
int n;
int a,b;
double c,d;
std::string str1,str2;
std::cin>>n;
while(n--) {
std::cin>>a >> b ;
std::cin>>c >> d;
std::cin >> str1 >>str2;
std::cout <<myplus(a, b) << endl;
std::cout <<myplus(d, c) << endl;
std::cout <<myplus(str1, str2) << endl;
}
return 0;
}
Submission
overload.h
#include<string>
#include<stdio.h>
using namespace std;
int myplus(int a,int b){
return a+b;
}
double myplus(double a,double b){
return a+b;
}
string myplus(string a,string b){
return a+b;
}
Standard Answer
overload.h
#include<iostream>
using namespace std;
int myplus(int a, int b);
double myplus(double a, double b);
string myplus(string a, string b);
int myplus(int a, int b){
return a+b;
}
double myplus(double a, double b){
return a+b;
}
string myplus(string a, const string b) {
return a+b;
}