i read in Turbo c++ in help tab that iostream is a class but till I knw my lecturer taught us that it is an header file so which one is true iostream is an header file or a class??
Asked
Active
Viewed 1,312 times
1
-
6I suggest you [pick up a good book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – Jun 07 '12 at 03:06
2 Answers
2
... Or both. You can include the header <iostream>
and there is a type std::iostream

David Rodríguez - dribeas
- 204,818
- 23
- 294
- 489
-
-
1@keerthi, You probably wouldn't ever use the class directly, but it's there inside the header. – chris Jun 07 '12 at 02:39
-
@keerthi: There is a header file `
` and there is a class template `std::iostream` – Blastfurnace Jun 07 '12 at 02:40 -
1@keerthi: [This reference](http://en.cppreference.com/w/cpp/io) shows how the stream-based I/O library is organized. – Blastfurnace Jun 07 '12 at 02:44
-
-
-
2@keerthi: Both. There is a header file called `
` and there is also `std::iostream` which is a class template typedef. – Blastfurnace Jun 07 '12 at 02:50
1
iostream is indeed a class in C++. You obtain access to this class by including the file named iostream in your code:
// SomeFile.cpp
#include <iostream>
// Some code that makes use of the class iostream...
This also holds for other stream classes within C++ such as istream, ostream, fstream, and so forth. Dig around in the include directory of your C++ installation to get a look at these classes if you wish.
This is of course a very common situation in C++ since one often encounters classes whose actual definitions are stored in files with the same name as the class but with .hpp or .cpp extensions.

pmcs
- 1,123
- 10
- 16
-
1so...iostream is a file/header file...in which iostream class exists and which we use in our programs??right?? – keerthi Jun 07 '12 at 02:44