# iostream and fstream

## Recommended Posts

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 on other sites
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 on other sites
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.

Too slow[smile][/edit]

##### Share on other sites
Quote:
 Original post by SiCraneifstream and ofstream are both defined in the 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.. :=/

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628375
• Total Posts
2982317

• 10
• 9
• 14
• 24
• 11