I know that heap allocation of ifstream is advised against, but for the sake of education, I tried allocating using new[] and using pointer to the newly allocated memory as seen below:
Code:
void lexer(ifstream* inputfile)
{
string line;
getline(*inputfile,line);
}
ifstream* inputbuffer()
{
ifstream* inputfileptr = new ifstream[10];
ifstream inputfile;
inputfile.open ("C:\\Product Description.txt");
*inputfileptr = inputfile;
return inputfileptr;
}
int main()
{
lexer(inputbuffer());
return 0;
}
I get a compiler error. The error message mentions:
'std::ios_base& std::ios_base:
perator=(const std::ios_base&)' is private
It doesnt mention what line it is but actually opens up some very long 1000 line .cpp file that I assume is the class code for ifstream. When I blank out line 12, it seems to compile so I assume line 12 is the problem.