I posted a question with my code whose only #include
directive was the following:
#include <bits/stdc++.h>
My teacher told me to do this, but in the comments section I was informed that I shouldn't.
Why?
I posted a question with my code whose only #include
directive was the following:
#include <bits/stdc++.h>
My teacher told me to do this, but in the comments section I was informed that I shouldn't.
Why?
Why? Because it is used as if it was supposed to be a C++ standard header, but no standard mentions it. So your code is non-portable by construction. You won't find any documentation for it on http://cppreference.com So it might as well not exist. It's a figment of someone's imagination :)
Including
<bits/stdc++.h>
appears to be an increasingly common thing to see on Stack Overflow, perhaps something newly added to a national curriculum in the current academic year.I imagine the advantages are vaguely given thus:
#include
lineUnfortunately, this is a lazy hack, naming a GCC internal header directly instead of individual standard headers like
<string>
,<iostream>
and<vector>
. It ruins portability and fosters terrible habits.The disadvantages include:
Don't do it!
More information:
Example of why Quora is bad: