Compile error on porting

Hi,

I've been making a program in C++ for Windows, and now I'm trying to port it to linux. I already fixed some errors that came up to me, like I used _itoa_s functions but those probably only worked on VC++. Anyway, I'm getting this kind of errors now:
/usr/include/c++/4.4/bits/ios_base.h:790: error: ‘std::ios_base::ios_base(const std::ios_base&)’ is private
/usr/include/c++/4.4/iosfwd:47: error: within this context

This happends when it starts compiling this file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "CreateTextFile.h"
#include <fstream>
#include "Exception.h"

using namespace PEARL;
using namespace std;

void PEARL::CreateTextFile(string filePath, string content)
{
	ofstream textFile = ofstream(filePath.c_str());
	if (textFile.is_open() && content.length() != 0)
	{
		textFile << content;
		textFile.close();
	}
	else
		throw new Exception("Unable to open file \"" + filePath + "\"");

}


Anybody a clue?
Ok, it seems to go away when I replace this line
ofstream textFile = ofstream(filePath.c_str());
With these lines:
1
2
fstream textFile;
textFile.open(filePath.c_str());

But I still want to know why :P.
Last edited on
Try:
ofstream textFile( filePath.c_str() );

Here's a thread that discusses this in more detail:
http://cplusplus.com/forum/general/20208/
Last edited on
Topic archived. No new replies allowed.