Jump to content
  • Advertisement
Sign in to follow this  

Include & Ostream issue

This topic is 3277 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

I'm using Visual Studio 2008, and working off an old project originally written/compiled in Visual Studio 6.0 Currently, this code is giving me problems:
//headerfile.h

#include <fstream>

class CTrace
{
  /* unrelated class code */
  void dump_to_file(ofstream *pout_stream);
};

template <class T> class Trace_Array
{
  T *m_parray;
  DWORD m_array_size;
  DWORD m_index;
  ofstream m_fout;
public:
  ofstream *get_fstream(void){return &m_fout;}
  DWORD get_size(void){return m_array_size;}
  void reset(DWORD new_index){m_index = (new_index % m_array_size);}
  Trace_Array(DWORD size, char *fname)
  {
    m_parray = new T[size];
    m_array_size = size;
    m_fout.open(fname);
    m_index = 0;
  }
  virtual ~Trace_Array(void)
  {
    if(m_fout.is_open())
      m_fout.close();
    
    if(m_parray)
    {
      delete [] m_parray;
      m_parray = NULL;
    }
  }

  T *operator++(int)
  {
    T *curobj;
    if(m_parray)
    {
      curobj = &m_parray[m_index];
      m_index++;
      m_index %= m_array_size;
      return curobj;
    }
    return NULL;
  }
};

I am getting errors like these (in general, it has a problem with "ofstream"): error C2143: syntax error : missing ';' before '*' error C4430: missing type specifier - int assumed. Note: C++ does not support default-int I'm pretty sure it has something to do with the include files I'm using. I changed the original set of includes from: #include <fstream.h> //to #include <fstream> I also tried using #include <ofstream> to no avail. Any help?, also, how do you add code tags so it's formatted nicely? [Edited by - TylerMoore on June 1, 2009 12:37:16 PM]

Share this post


Link to post
Share on other sites
Advertisement
You can use [code] or [source] to format code. As for your compiler errors, it seems that you need to account for the fact that ofstream and related classes live in the std namespace. So you'd use std::ofstream, etc.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!