I´m getting this error in a c++ application:
error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' :
cannot access private member declared in class '
I have seen similar questions in stackoverflow, but I couldn't figure out what's wrong with my code. Can someone help me?
//header file
class batchformat {
public:
batchformat();
~batchformat();
std::vector<long> cases;
void readBatchformat();
private:
string readLinee(ifstream batchFile);
void clear();
};
//cpp file
void batchformat::readBatchformat()
{
ifstream batchFile;
//CODE HERE
line = batchformat::readLinee(batchFile);
}
string batchformat::readLinee(ifstream batchFile)
{
string thisLine;
//CODE HERE
return thisLine;
}
The problem is:
string readLinee(ifstream batchFile);
This tries to pass a copy of the stream by value; but streams are not copyable. You want to pass by reference instead:
string readLinee(ifstream & batchFile);
// ^
string batchformat::readLinee(ifstream batchFile)
正试图复制ifstream取而代之的是ref
string batchformat::readLinee(ifstream& batchFile)
Your error is that you can not pass the ifstream by value :
string readLinee(ifstream batchFile);
Pass it by ref instead :
string readLinee(ifstream& batchFile);
And I would suggest you to change a lign in the readBatchformat
method :
void batchformat::readBatchformat()
{
ifstream batchFile;
//CODE HERE
line = this->readLinee(batchFile);
// ^^^^^^
}
I think it is more readable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.