一个关于stringstream的问题求助.
  • 板块学术版
  • 楼主Pjcgs
  • 当前回复3
  • 已保存回复3
  • 发布时间2022/10/15 15:44
  • 上次更新2023/10/27 07:26:07
查看原帖
一个关于stringstream的问题求助.
768410
Pjcgs楼主2022/10/15 15:44
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
template<class TA,class TB>
TB AtoB(const TA &a)
{
    stringstream st;
    st<<a;
    TB b;
    st>>b;
    return b;
}
int main()
{
    int x=123;
    string y;
    y=AtoB<int,string>(x);
    cout<<"strinf:"+y<<endl;
    y="-126";
    x=AtoB<string,int>(y);
    cout<<x*100;
    return 0;
}

y=AtoB<int,string>(x); 是什么意思?类型比大小??

2022/10/15 15:44
加载中...