Jump to content
  • Advertisement
Sign in to follow this  
bah

Cannot use ofstream from fstream...

This topic is 4827 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I want to use ofstream from <fstream> but the compiler won't let me. The following is the class definition: <code> class DebugManager { private: ofstream m_log; bool m_ready; public: DebugManager(); virtual ~DebugManager(); friend void DebugManager_Write(...); }; </code> The first error, C2146, is at the line where m_log is defined and that starts an avalanche of other errors.

Share this post


Link to post
Share on other sites
Advertisement
Try using std::ofstream, or typing using namespace std; outside the class.
What this mean is that ofstream is in the std namespace, and you must tell your compiler that you want to access ofstream from the namespace std. By typing out using namespace std; somewhere at the top of your page you tell the rest of that page to use the std namespace by default, and you can write ofstream m_log instead of std::ofstream m_log.

Share this post


Link to post
Share on other sites
Thanks SiCrane, it works fine now. I should have remembered to include the namespace. :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!