本文介绍了什么是外联动和内联动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解外部链接和内部链接以及它们的区别.

I want to understand the external linkage and internal linkage and their difference.

我也想知道

const 变量默认在内部链接,除非另外声明为 extern.

推荐答案

当您编写实现文件(.cpp.cxx 等)时,您的编译器会生成一个翻译单元.这是来自您的实现的源文件以及您在其中 #include d 的所有标头.

When you write an implementation file (.cpp, .cxx, etc) your compiler generates a translation unit. This is the source file from your implementation plus all the headers you #included in it.

内部链接是指翻译单元范围内的所有内容.

外部链接是指存在于特定翻译单元之外的事物.换句话说,可通过整个程序访问,即所有翻译单元(或目标文件)的组合.

External linkage refers to things that exist beyond a particular translation unit. In other words, accessible through the whole program, which is the combination of all translation units (or object files).

这篇关于什么是外联动和内联动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 02:10