c++ compiler error cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'

后端 未结 4 2024
执笔经年
执笔经年 2020-12-22 11:38

Hey Im getting an error I think has to do with copying ofstream variable from reading other posts and Ive tried to change

std::ofstream outfil;
4条回答
  •  感情败类
    2020-12-22 11:59

    You are declaring outfil as a reference to an object of type std::ofstream with the following line in main:

    std::ofstream & outfil;
    

    References must be initialized upon declaration. Your solution is to declare outfil as:

    std::ofstream outfil;
    

提交回复
热议问题