【发布时间】:2020-02-03 08:17:30
【问题描述】:
我正在开发一个 C++ Windows 窗体应用程序,当用户单击按钮时,它会从 txt 文件中读取点击计数,然后执行一些功能并将新的点击计数写回 txt 文件。
当只有ofstream代码时,它运行良好。但是在我添加了ifstream代码之后,出现了这个错误:
错误 C2678:二进制“>>”:未找到采用“std::ifstream”类型的左侧操作数的运算符(或没有可接受的转换)
我已经包含了<fstream> 和<iostream>。
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
//Some visible and invisible code for label
std::ifstream file1;
file1.open("Progress.txt");
file1 >> clickcount;
file1.close();
clickcount = ++clickcount;
...
std::ofstream file;
file.open("Progress.txt");
file << clickcount;
file.close();
【问题讨论】:
-
对不起。我已经编辑过了
-
clickcount声明为什么? -
public ref class NNYT : public System::Windows::Forms::Form { unsigned short int clickcount = 0 ...