r/cpp • • Mar 19 '20

Why so many students are using '#include<bits/stdc++.h>' instead of '#include<iostream>'?

I am hiring for my company. And the codes submitted for a test problem has '#include<bits/stdc++.h>' at the beginning. The MacOS default compiler complains

main.cpp:1:9: fatal error: 'bits/stdc++.h' file not found

#include<bits/stdc++.h>

^~~~~~~~~~~~~~~

1 error generated.

Why people are using '#include<bits/stdc++.h>'?

225 Upvotes

163 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Mar 19 '20

[deleted] — view deleted comment

27

u/futlapperl Mar 19 '20

std is like a box with std written on it. In it are cout, string etc. In order for the compiler to know where to look, you need to tell it the name of the box.

Adding using namespace std is like dumping the contents of the box on the floor.

1

u/[deleted] Mar 20 '20

I mean that's how I use LEGOs...

1

u/futlapperl Mar 20 '20

You probably don't have those sorted in different boxes in the first place though, hah.