什么是头文件和库之间的区别? [英] What's the difference between a header file and a library?
问题描述
一个我有一个很难理解的事情是编译器是如何工作的。我有很多与它的困难,但特别是我不断收到标题和混了库。如果有人能搞清楚一点,那简直太好了。
One of the things I'm having a hard time understanding is how the compiler works. I'm having a lot of difficulties with it, but in particular I keep getting headers and libraries mixed up. If somebody could clear things up a bit, that'd be great.
推荐答案
想想都像这样(免责声明:这是一个非常高层次的比喻;)。
Think of both like this (Disclaimer: this is a really high-level analogy ;) ..
- 在标题是您可以拨打一个电话号码,而...
- ...在库是实际的人,你可以到达那里!
- The header is a phone number you can call, while...
- ...the library is the actual person you can reach there!
它的接口和执行的根本区别;在接口的(头)告诉你如何以调用一些功能(不知道它是如何工作的),而实施的(库)是实际功能。
It's the fundamental difference between "interface" and "implementation"; the interface (header) tells you how to call some functionality (without knowing how it works), while the implementation (library) is the actual functionality.
请注意:这个概念是如此的根本,因为它可以让你的灵活性:你可以有不同的库相同的标题(即功能正是所谓以同样的方式),以及每个磁带库可以的实施以不同的方式的功能。通过保持相同的接口,可以更换库不改变的您的code。
Note: The concept is so fundamental, because it allows you flexibility: you can have the same header for different libraries (i.e. the functionality is exactly called in the same way), and each library may implement the functionality in a different way. By keeping the same interface, you can replace the libraries without changing your code.
和:你可以改变库的实现而不会破坏调用code
And: you can change the implementation of the library without breaking the calling code!
这篇关于什么是头文件和库之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!