keerthi
keerthi

Reputation: 77

Iostream is a class

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??

Upvotes: 1

Views: 1464

Answers (2)

pmcs
pmcs

Reputation: 1123

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.

Upvotes: 1

... Or both. You can include the header <iostream> and there is a type std::iostream

Upvotes: 2

Related Questions