Linkage(C++ Programming ) Questions and Answers
Explanation:-
Answer: Option C. -> prototypeBy defining a function's prototype in another file means, we can inherit all the features
from the source function.
Explanation:-
Answer: Option C. -> make the entity visible only to that blockNone.
Explanation:-
Answer: Option B. -> externextern keyword is used to represent identifiers from other programs.
Explanation:-
Answer: Option B. -> externalNone.
Question 5.
What will be the output of these two programs?
1.
1.
1.
#ifndef Exercise_H
2.
#define Exercise_H
3.
int num = 842;
4.
#endif
2.
1.
#include
2.
#include "exe.h"
3.
using namespace std;
4.
int main(int argc, char * argv[] )
5.
{
6.
cout
- 842
- 843
- compile time error
- none of the mentioned
Explanation:-
Answer: Option A. -> 842In this program, we have created a header file and linked that into the source program and we
are post incrementing that because of that it is printed as 842.
Output:
$ g++ link.cpp
$ a.out
842
Explanation:-
Answer: Option A. -> staticNone.
Explanation:-
Answer: Option C. -> 3There are three types of linkage in c++. They are internal linkage, external linkage and
no linkage.