Sign in to follow this  
OpenGL_Guru

iostream and fstream

Recommended Posts

OpenGL_Guru    104
i am into .NET now and i am switch ing from iostream.h/fstream.h to just iostream and fstream. when i try to declare something like.. ifstream infile; the compiler doesnt like these ... ofstream outfile; what is the common includes and/or declarations for this? thanks in advance!

Share this post


Link to post
Share on other sites
SiCrane    11839
ifstream and ofstream are both defined in the <fstream> header. Just remember that they live in the std namespace so you'll either need to say std::ifstream/std:ofstream or use a using directive or declaration.

Share this post


Link to post
Share on other sites
darookie    1441
Prefix with the std namespace:

std::ifstream infile;
std::ofstream outfile;

The main difference between the <xxx.h> and <xxx> is that the classes are declared
to reside in the std namespace.

[edit]Too slow[smile][/edit]

Share this post


Link to post
Share on other sites
OpenGL_Guru    104
Quote:
Original post by SiCrane
ifstream and ofstream are both defined in the <fstream> header. Just remember that they live in the std namespace so you'll either need to say std::ifstream/std:ofstream or use a using directive or declaration.


thanks...

i wasnt including using namespace std at the top... duh.. :=/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this