Reusing OFSTREAM Object

I get an access violation reading location error when I try to reuse an ofstream object. I made sure to close it and clear it within its scope, and I still get the error.

My code:


ProbabilityOutputFile->CloseFile();
ProbabilityOutputFile->~OutputFileHandler();
ProbabilityOutputFile->SetFileName(VoltageProtocol, CurrentProtocol, CurrentVoltageSignal, "Probability");
ProbabilityOutputFile->OpenFile(); //ERROR OCCURS HERE




void OutputFileHandler::CloseFile(){

OutputFile.close();
if (OutputFile.fail())
{
std::cout<<"\n File Failed to Close \n";
}
OutputFile.clear();

}

void OutputFileHandler::OpenFile()
{

OutputFile.open(FileName); //ERROR OCCURS HERE
if (OutputFile.is_open()){
std::cout<<"\n"<<"Output File was Opened \n";
}
}


So, whats going on?
Last edited on
Topic archived. No new replies allowed.