logo

Crowdly

Browser

Add to Chrome

Recall from HLP1 that internal variables are variables that are defined in fun...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Recall from HLP1 that internal variables are variables that are defined in function blocks while external variables are variables that are defined outside of any function. By default, internal variables have internal linkage while external variables have external linkage. Internal linkage of a variable implies the compiler doesn't export the variable's name to the linker, while external linkage of a variable implies the compiler will export the variable's name to the linker. Thus, in contrast to internal variables, external variables defined in one source file are accessible to functions defined in other source files. Programmers can force external variables to have internal linkage by adding storage specifier keyword static to the definition of the external variable, as in:

static int global_variable;

In C11, by default, read-only external variables [defined as read-only using type qualifier keyword const] have external linkage. Determine whether such read-only external variables have internal linkage or external linkage in C++ by examining the following C++ code in a source file:

#include <cstdio>

const int foo = 1;

int main() {

std::printf("%d\n", foo);

}

and the following code in a second source file:

const int foo = 4;

Which of the following choices best reflects the output of compilation [only] of each of two source files and the linkage of the corresponding two object files?

0%
0%
0%
0%
0%
More questions like this

Want instant access to all verified answers on distance3.sg.digipen.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome