Here is a listing of C++ questions and puzzles on “Linkage” along with answers, explanations and/or solutions:
1. How many types of linkages are there in C++?
Explanation: There are three types of linkage in c++. They are an internal linkage, external linkage, and no linkage.
2. To use internal linkage we have to use which keyword?
c) static or extern
Explanation: static keyword is used for internal linkage.
3. Which one is used to refer to program elements in any translation units?
a) internal linkage
b) external linkage
c) no linkage
d) internal & external linkage
Explanation: In the external linkage, it is used to refer to identifiers in various programs.
4. What will be the output of the following C++ codes?
int number = 842;
using namespace std;
int main(int argc, char * argv )
cout << number++;
c) compile time error
Explanation: In this program, we have created a header file and linked that into the source program and we post incrementing that because of that it is printed as 842.
$ g++ link.cpp $ a.out 842
5. What is the default type of linkage that is available for identifiers?
c) no linkage
d) single linkage
Explanation: external is the default type of linkage that is available for identifiers.
6. To use external linkage we have to use which keyword?
Explanation: Extern keyword is used to represent identifiers from other programs.
7. Which is used to use a function from one source file to another?
Explanation: By defining a function’s prototype in another file means, we can inherit all the features from the source function.
8. What is the use of no linkage?
a) make the entity visible to other programs
b) make the entity visible to other blocks in the same program
c) make the entity visible only to that block
d) make the entity invisible
Sanfoundry Global Education & Learning Series – C++ Programming Language.
To practice all areas of C++ language, here is complete set of 1000+ Multiple Choice Questions and Answers.