Fail to open / create a file

Hi,
When I write the Ctor as follows, I get an Error: Invalid Sharing Flag 0
(That happens when file exists or does not exist)

1
2
3
4
File::File(const string& file)
{
	m_file.open(file, std::ios::out, std::ios::app);
}


When I write the Ctor as foolows, I manage to open / create a file.
1
2
3
4
File::File(const string& file)
{
	m_file.open(file);
}


What is wrong with option #1?

Please note that m_file is a data member of type ofstream

Thank you.
Last edited on
ifstream::open takes 2 parameters, not 3.
http://en.cppreference.com/w/cpp/io/basic_ofstream/open

As openmode is a bit mask, you need to add two modes together:
m_file.open(file, std::ios::out | std::ios::app);
Topic archived. No new replies allowed.