Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Confused ....

This topic is 5458 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 have a very simple class, the prototype of which is shown below:

namespace Eden {

// log file results
typedef enum tagLogFileResult{LOGFILE_ERROR=0,
							  LOGFILE_COULDNOTOPEN} LogFileResult;

// EDEN_API = __declspec(dllexport) for compiling engine
// and __declspec(dllimport) for users of the engine
class EDEN_API CLogFile
	std::ofstream OutputFile;
	/*CLogFile(const CLogFile&);
	LogFileResult Open(const std::string c_FileName_);
	void Close();			
	LogFileResult Write(const EdenChar *cp_acMsg_, ...);



The compiler (Visual C++ 7) will not generate an asignment operator & copy functions for this class. Which basically means i cant even go

LogFile1 = LogFile2 

And this is stopping me using a vector for holding an varying size array of log files which is what my object manager needs to do ... 

Now I have much more complex classes in the engine and the compiler seems to have 0 problems whith generating the operators and methods for those.

So fearing some bug in my compiler i wrote my own copy constructor and I get the following error:

c:\MikesStuff\Programming\Eden\engine\CLogFile.cpp(53): error C2582: ''operator ='' function is unavailable in ''std::basic_ofstream<_Elem,_Traits>''

Is this a design trait of ofstream that you cant assign it to another ofstream or is it my compiler being a little strange or me just being a crap programmer ?

Ok I AM using the multi threaded debug dll libaries so the fact that the class resides in a dll and the usage is in a win32 app shouldnt be a problem should it?

If I am just misunderstanding basic c++ please say so and tell me off . This is my first major project using Visual C++ compiler so... 

Thanks in advance.


Share this post

Link to post
Share on other sites
streams do not have assignment or copy constructors defined, simply because there''s no conceptually reasonable way to duplicate an object that refers to a non-duplicatable resource (like the console).

You COULD use a reference-counted scheme, and have a pointer to the ofstream. Look into the smart pointer classes at http://www.boost.org.

How appropriate. You fight like a cow.

Share this post

Link to post
Share on other sites

  • 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!