[Error] no match for 'operator>>' (opera

qq_32578411 2015-11-17 10:27:20
#include<iostream>
#include <string>
#include <fstream>
using namespace std;

int main()
{
ofstream output;

output.open("number.txt");

output<<95<<" "<<56<<" "<<34;

output.close();

cout<<"Done"<<endl;

ofstream input;


input.open("number.txt");

int score1 ,score2 ,score3;

input >> score1;
input >> score2;
input >> score3;

cout<<"Total score is "<<score1+score2+score3<<endl;

input.close();

cout<<"Done"<<endl;

return 0;
}


25 8 F:\c++\Dev.cpp\SimpleFileinput.cpp [Error] no match for 'operator>>' (operand types are 'std::ofstream {aka std::basic_ofstream<char>}' and 'int')
求大神解答
...全文
2801 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
paschen 2015-11-17
  • 打赏
  • 举报
回复
改成 ifstream input;
qq_32578411 2015-11-17
  • 打赏
  • 举报
回复
谢谢 你的回答
fefe82 2015-11-17
  • 打赏
  • 举报
回复
ofstream input; ofstream 是用来输出的。输入用 ifstream

33,316

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧