我想制作一个可以添加字符串(串联)和数字(int或float)的程序。程序有效,但最后它也输出Trap,我没有写过,所以它表示什么 很抱歉给您带来不便。
#include <iostream>
#include <cmath>
#include <cstring>
#include <typeinfo>
using namespace std;
template <class test>
class Test {
public:
test operator+(){
test Ss= typeid("hi").name();
test a,b,c;
if(a == Ss){
a.concat(b);
}else{
test c = a+b;
}
}
test ask_f(test a, test b){
test c=a+b;
cout<<c<<end;
};
int main(){
Test <int> t1;
t1.ask_f(5,6);
}