error C2653: 'ios' : is not a class or namespace name

J

Joseph Lu

Hi,all
I have code like the following lines, but when I compile this program I
got a: error C2563 : 'ios' : is not a class or namespace name!

//--Code starts here
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>

... ...
fstream fFile;
fFile.open("c:\testfile.dat",ios::binary|ios::in,0);
fFile<<"XXX";
fFile.seekp(dwBlockSize,ios::beg);

//--Code ends here

ERROR OCCURED --> error C2653: 'ios' : is not a class or namespace name

Could anybody tell me why, thanks a lot

Joseph
 
B

Bruno van Dooren [MVP VC++]

I have code like the following lines, but when I compile this program I
got a: error C2563 : 'ios' : is not a class or namespace name!

//--Code starts here
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>

I assume you've got 'using namespace std;' here somewhere?
... ...
fstream fFile;
fFile.open("c:\testfile.dat",ios::binary|ios::in,0);
fFile<<"XXX";
fFile.seekp(dwBlockSize,ios::beg);

from the documentation it seems that ios is legacy. you should ios_base:
file.seekp( 0, ios_base::beg );

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
T

Tom Widmer [VC++ MVP]

Bruno said:
I assume you've got 'using namespace std;' here somewhere?


from the documentation it seems that ios is legacy. you should ios_base:
file.seekp( 0, ios_base::beg );

ios is a typedef for basic_ios<char> (which is derived from ios_base),
so it should work fine with ios (or certainly std::ios), as long as an
appropriate header (<ios>, <iosfwd>, or, bizarrely, <bitset>) is included.

Tom
 
J

Joseph Lu

Yes, thanks a lot!

Bruno van Dooren said:
I assume you've got 'using namespace std;' here somewhere?


from the documentation it seems that ios is legacy. you should ios_base:
file.seekp( 0, ios_base::beg );

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top