Thursday, October 25, 2018

c++ - What is external linkage and internal linkage?



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




I also want to know the meaning of




const variables internally link by default unless otherwise declared as extern.



Answer



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



Internal linkage refers to everything only in scope of a translation unit.




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).


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...