[英]C++ whats wrong with that code fstream
需要有关C ++代码的帮助
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
class open_file
{
string list_cont;
fstream newlist;
newlist.open("lista.txt",ios::in);
while (newlist.good())
{
getline(newlist, list_cont);
cout << list_cont << endl;
}
newlist.close();
};
Visual Studio不断使我得到错误102错误C2143:语法错误:缺少';' 在“。”之前
Duno为什么,有什么想法?
提前致谢
用void open_file()
替换class open_file
,并删除最后一个分号。 您的问题是您试图声明一个函数,但改用了class关键字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.