473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

what diffierent between ios_base and ios ?

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
fstream inOut( "copy.out", ios_base::in|ios_base::app );
int cnt=0;
char ch;
inOut.seekg(0);
while ( inOut.get( ch ) )
{
cout.put( ch );
cnt++;
if ( ch == '\n' )
{
ios_base::pos_type mark = inOut.tellg();
/*here is an error , but if replace with
"ios::pos_type mark = inOut.tellg();"
it will work well .
can you tell me why?
*/
inOut << cnt << ' ';
inOut.seekg( mark );
}
}
inOut.clear();
inOut << cnt << endl;
cout << "[ " << cnt << " ]\n";
system("pause");
return 0;
}

Jul 23 '05 #1
1 3629
ios_base::pos_type mark = inOut.tellg();
/*here is an error , but if replace with
"ios::pos_type mark = inOut.tellg();"
it will work well .
can you tell me why?


Because pos_type is a typedef within ios (defined in the ios standard
header, as _Traits::pos_type), not a member of the ios_base class. The
ios_base members are things like in, out, failbit, etc, not the "types" such
as pos_type, int_type, etc.

You can look them up in the headers for yourself, if you're interested.

-Howard

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: ben | last post by:
When I try to gcc the following Helloworld program: #include <iostream> int main() { using namespace std; cout << "Hello, World!!\n"; return 0; }
2
by: Generic Usenet Account | last post by:
What exactly is the difference between the hex manipulator and the following statement: cout.setf(ios_base::hex)? According to Stroustrup, Third Edition, Section 21.4.4, "once set, a base is...
3
by: Boris | last post by:
After including sstream the compiler reports hundreds of errors. They are all caused by a missing ios_base definition. When I search for ios_base in the installation directory of VS.NET 2003 I find...
6
by: Geoffrey S. Knauth | last post by:
It's been a while since I programmed in C++, and the language sure has changed. Usually I can figure out why something no longer compiles, but this time I'm stumped. A friend has a problem he...
7
by: DaVinci | last post by:
//error happen even when there existe a a.txt file #include<fstream> #include <string> #include <iostream> using std::string; using std::fstream; int main() { string s = "a.txt"; fstream...
6
by: paul.anderson | last post by:
This code doesn't work - the first retrieval of t2 returns valid data, the subsequent do not. Please help!!! int main(int argc, char* argc){ struct Test{ int i; int j; intk; int l; }
9
by: Robin | last post by:
// Pls note that test.txt exists. #include <iostream> #include <fstream> #include <string> using namespace std; int main() { fstream fs("test.txt", ios_base::in | ios_base::app);
2
by: Robert | last post by:
dear sir: I have read the c++ primer plus 5 book, and do the chapter 12 programming exercises question 5, but the average_wait have negative result. I don't understand why? here is the code,...
13
by: ishakarthika | last post by:
how can i compare the a private variable of a class and a value in the column of a text file. there is a syntax error in my code while comparing. senario is i am getting bus details like busno,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.