为什么我不应该#include< bits / stdc ++。h> ;? [英] Why should I not #include <bits/stdc++.h>?
问题描述
我对我的代码发布了一个问题,其中只有 #include
指令如下:
#include< bits / stdc ++。h>
我的老师告诉我这样做,但在评论部分我被告知我不应该
为什么?
< bits / stdc ++。h> 似乎是Stack Overflow上越来越常见的东西,也许是在当前学年新增加到国家课程中的东西。
我想象的优点是这样含糊的:
- 你只需要写一个
include
行 - 您不需要查找 中包含的标准标题
不幸的是,这是一个懒惰的黑客,直接命名一个GCC内部头文件,而不是像< string>
, < iostream>
和< vector>
。
缺点包括:
- 你不知道在使用它时它会做什么,因为它的内容不是由标准设置的
- 即使只是将您的编译器升级到自己的下一个版本也可能会破坏您的程序
- 每个标准标头都必须与您的源代码一起解析和编译,可在特定编辑设置下执行。
b $ b 详细信息: Quora为什么不好的示例: I posted a question with my code whose only My teacher told me to do this, but in the comments section I was informed that I shouldn't. Why? Including I imagine the advantages are vaguely given thus: Unfortunately, this is a lazy hack, naming a GCC internal header directly instead of individual standard headers like The disadvantages include: Don't do it! More information: Example of why Quora is bad: 这篇关于为什么我不应该#include< bits / stdc ++。h> ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
#include
directive was the following:#include <bits/stdc++.h>
<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.
#include
line<string>
, <iostream>
and <vector>
. It ruins portability and fosters terrible habits.