C++ fstream-无法访问在类basic中声明的私有成员\u fstream

C++ fstream-无法访问在类basic中声明的私有成员\u fstream,c++,ios,iostream,fstream,C++,Ios,Iostream,Fstream,我使用fstream打开一个文件以供编写 fstream streamFile; streamFile.open ( "C:\\path\\to\\textFile.txt", fstream::in | fstream::out| fstream::app); 我得到以下错误: cannot access private members declared in class basic_fstream<_Elem, _Traits> 少了什么 #include <io

我使用fstream打开一个文件以供编写

fstream streamFile;  
streamFile.open ( "C:\\path\\to\\textFile.txt", 
fstream::in | fstream::out| fstream::app);
我得到以下错误:

cannot access private members declared in class basic_fstream<_Elem, _Traits>
少了什么

#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    fstream streamFile;
    streamFile.open("C:\\Robin\\input.txt",
        fstream::in | fstream::out | fstream::app);
    if (streamFile.is_open())
    {
        streamFile << "Hej" << endl;
        streamFile.close();
    }

    return 0;
}

这是我的全部代码,它工作正常,不会触发任何错误。它在给定目录中创建或追加.txt文件。没有问题。与此进行比较,看看是否有什么不同之处

为我工作,你能添加更多的代码吗?这是全部代码。这种错误的触发因素是什么?你遇到过吗?请创建一个并向我们显示,如果在构建时有更多消息,请显示所有消息。谢谢。错误引用了类fstream,代码为:private:\u Myfb\u Filebuffer;};。有什么想法吗?我必须说,像@Joachim Pileborg,请创建一个最小的、完整的、可验证的示例并向我们展示,如果在构建时有更多的消息,请展示所有消息。