Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

ifstream and ofstream problem

joanadiasjoanadias Member Posts: 1
I am programming using Visual studio C++, doing some win32 console application simple programs.
I am upgrading to visual studio 2008, and I cannot compile programs in C++ done with previous versions (6.0) because I always get a compiler error. For instance, if I write:

ifstream f("file.txt")

then the compiler tells me: "ifstream: undeclared identifier", although I have included fstream header file.

I am also having problems with two classes that I defined as "friends", but the compiler does not let me reference private members of one another...
Could someone tell me what to do?
Thank you.

Comments

  • MT2002MT2002 Member Posts: 1,444
    Visual C++ 6 includes a horrible non standard C++ compiler, which is probably why you receive errors compiling in 2005. It was developed when C++ was not standardized yet.

    To fix the ifstream problem, try this:
    [code]#include

    std::ifstream f("file.txt"); //...in your routine[/code]

    You can also use [b]using namespace std[/b] so you do not need to prefix with [b]std::[/b]. Be careful not to do this in header files, however.

    Can you post some code where you declare your friend classes?
    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.brokenthorn.com]Website :: OS Development Series[rightbr][/link][/size]
Sign In or Register to comment.