永发信息网

#include<iostream> #include<fstream> #include<string> using namespace std; void ma

答案:1  悬赏:40  手机版
解决时间 2021-03-15 16:03
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
void main()
{
ofstream fout;
fout.open("1.txt");
ifstream fin("1.txt");
string a,b="12";
cin>>a;
fout<<a;
fout.close();
fin>>a;
cout<<a-b;
}
:\users\wentian\desktop\新建文件夹\0.cpp(15) : error C2784: '_D __cdecl std::operator -(const class std::reverse_iterator<_RI,_Ty,_Rt,_Pt,_D> &,const class std::reverse_iterator<_RI,_Ty,_Rt,_Pt,_D> &)' : could not deduce template argument for 'cons
t class std::reverse_iterator<_RI,_Ty,_Rt,_Pt,_D> &' from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
c:\users\wentian\desktop\新建文件夹\0.cpp(15) : error C2676: binary '-' : 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a conversion to a type acceptable to the predefined
operator
执行 cl.exe 时出错.

0.obj - 1 error(s), 0 warning(s)
请教高手!
最佳答案
cout<<a-b; a和b是 string class(类),没有 减运算 "-"。所以语法错。
string class 有 "+" 运算, 但不是做数学加法,而是把两个字符串连起来。
改成 cout<< (a+b); 就可以了。

string class(类),有比较运算,==, > , <, != 等。

有时,用 char 数组,比用 string class 方便。看你 a-b 到底 是要做什么运算。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
蕌头炒鸡蛋的做法,蕌头炒鸡蛋怎么做好吃,蕌
中国邮政(池口邮政所)地址在哪,我要去那里办
一座山一条河打一成语的答案
舔女友脚的时候她会高潮是什么原因
满足不等式2x-1>-5的非正整数解有________.
微信登录环境异常限制 多久微信不会出现
清真饭庄在哪里啊,我有事要去这个地方
在合肥市,要做饮用矿泉水中矿物质含量检测,
输入您的问题赛尔号米米号忘了怎么办
泰合商业广场我想知道这个在什么地方
手机内存卡快坏了 都有什么表现
文竹鲜花店我想知道这个在什么地方
中国春节去哪旅游好玩
正处级干部应该什么车,自治区的正处级干部
迈道夫地址在哪,我要去那里办事
推荐资讯
成都哪儿能买到静注丙种球蛋白(规格:2.5g,
计算机操作员四级考试
苏剧的《经年》 写的是什么主题啊
一般过去式问题,帮我答一下,顺便告诉我为什
我要用16:9的led大屏播放ppt,请问可以播放
to fight to the last man
冲锋衣适合日常穿着吗?
武汉光谷房价涨得这么疯 现在还能买那里的房
求梦幻西游快一天能刷500三界功绩以上的办法
ps4上自定义图形工具在哪
玉霞水暖电料地址在哪,我要去那里办事
目前购买一辆五菱荣光加长版面包车,所有手续
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?