Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does iostream header file not get included?

Tags:

c++

io

#include <sstream>
using namespace std;

int main()
{
    cout << "hi"; // error: undeclared cout
}

From what I have read, sstream class is derived from iostream class but why does it not get included automatically?

like image 294
user756327 Avatar asked Mar 21 '26 16:03

user756327


1 Answers

The iostream-based classes are not the same as the iostream header. Standard headers do not have to include each other, or may include each other in any order. If you wish to use the contents of <iostream>, you must #include <iostream>.

like image 192
Puppy Avatar answered Mar 23 '26 04:03

Puppy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!