I have the following constructor for a class:
When I call the constructor to open a file for the class it opens the file and goes through all the lines happily, it doesn't enter the if statement. However the minute the constructor has finished I find that the file has been closed. I'm not sure why, I've checked with my debugger and the code does not enter the destructor, nor am I trying to use the class outside of the scope I declared it in so I can't figure out what is going on. Why is the file being closed after the constructor has finished?
Code:
Cdata::Cdata(char *input)
{
//Try and open the input file
ifstream ifile(input, ios::in);
if(!ifile.is_open())
{
cout << "The input file didn't open!" << endl;
exit(1);
}
}