Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualBacterius

Posted 21 October 2012 - 04:39 PM

Sanity check: does this work for you?

[source lang="cpp"]#include < iostream >#include < fstream >using namespace std;class DebugLog {public:DebugLog();void writeTo(string text);~DebugLog();private:ofstream m_debugLog;};DebugLog::DebugLog(){ m_debugLog.open("DebugLog.txt");}DebugLog::~DebugLog(){ cout < < "Closing debug log." < < endl; m_debugLog.close();}void DebugLog::writeTo(string text){ m_debugLog < < text;}int main(){ DebugLog log; log.writeTo("hello world"); // log is about to fall out of scope - destructor should be called return 0;}[/source]

Remove all the extra spaces I had to insert since the source tags are broken. I think we're just having a communication breakdown here.

#1Bacterius

Posted 21 October 2012 - 04:38 PM

Sanity check: does this work for you?

[source lang="cpp"]#include < iostream >#include < fstream >using namespace std;class DebugLog {public:DebugLog();void writeTo(string text);~DebugLog();private:ofstream m_debugLog;};DebugLog::DebugLog(){ m_debugLog.open("DebugLog.txt");}DebugLog::~DebugLog(){ cout < < "Closing debug log." < < endl; m_debugLog.close();}void DebugLog::writeTo(string text){ m_debugLog < < text;}int main(){ DebugLog log; log.writeTo("hello world"); // log is about to fall out of scope - destructor should be called return 0;}[/source]

Remove all the extra spaces I had to insert since the source tags are broken. I think we're just having a communication breakdown here.

PARTNERS