Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot use ofstream members

Status
Not open for further replies.

UnknownPerson

Programmer
Dec 4, 2001
80
BR
Someone please help:

In one of my coding works, I needed a class wich manipulated records on a file. As such, I made a ostream member as in:

class SomeClass {
ostream TheFile;
};

To my surprise, any attemp to TheFile.open(....) fails, no matter what the parameters. Anyone have a clue?. I made the following test:

SomeClass::OpenSomeFile(std::string& Name)
{
TheFile.open(Name.c_str()); // FAILS!!!!
ostream SomeOtheFile(Name.c_str()); // Works perfectly
}

Any ideas???

Notes: Using MSVC++ v5.0 Enterprise. I sent this message to 3 different C++ related discussion rooms.
 
I´m sorry, just to correct some typos in the post.
Corrections are:

class SomeClass {
ofstream TheFile;
};

And:

SomeClass::OpenSomeFile(std::string& Name)
{
TheFile.open(Name.c_str()); // FAILS!!!!
ofstream SomeOtheFile(Name.c_str()); // Works perfectly
}

This is only a correction of my typos. The problem still exists. Any help?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top