为什么STL头文件没有扩展名?
我有这个基本的疑问。 STL 标头没有 .h
扩展名。
#include <vector>
#include <map>
这背后有什么具体原因吗? 谁知道这背后的历史,请分享。
编辑:
@GMan 发现 迈克尔·伯尔的回答 这解决了这个问题。
I got this basic doubt.
The STL header doesn't have .h
extension.
#include <vector>
#include <map>
Is there is any specific reason behind this? Anybody knows history behind this, please share.
EDIT:
@GMan found Michael Burr's answer
which addresses this question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这一切都与命名空间有关。 C++ 标准头的 .h 对应项通常 #includes 正确的 C++ 标准头(不带 .h 扩展名),然后发出一堆使用(类似这样):
FILE: iostream.h
而没有 .h 扩展名的头文件则不会用所有定义的类和类型污染命名空间。
It all has to do with namespaces. The .h counterparts for C++ standard headers usually #includes the proper C++ standard header (without .h extension) and then issues a bunch of using (something like this):
FILE: iostream.h
whereas the headerfile without the .h extension does not pollute the namespace with all the defined classes and types.