(For those who already know C or C++) What is the binding time for each of the f
ID: 3742050 • Letter: #
Question
(For those who already know C or C++) What is the binding time for each of the following in a C or C++ program? State the binding time as precisely as possible (language-definition time, language-implementation time, compile time, link time, load time, or runtime). Explain how each of the following is bound and why it is bound when it is.
a. The location in memory of a local variable in a function.
b. The meaning of the keyword while.
c. The size in memory of a variable of type int.
d. The location in memory of a global static variable.
e. The code for the printf function.
f. The type of a local variable in a function.
g. The value(s) assigned to a variable.
h. The size in memory of a pointer.
Explanation / Answer
a.The location in memory of a local variable in a function: Runtime -> values to variables and virtual function, object creation etc is done at runtime. The values of local variable is assigned in runtime stack memory and done at runtime.
b. The meaning of the keyword while: Language Design time->Built in function, keywords and fundamentals binding are specified at language design time. As while is keyword, so its meaning would be binded at language design time.
c.The size in memory of a variable of type int: Language implementation time-> various runtime exception, size of each data type and represenatation of file is specified at language implementation time. int is a data type and it's size should be specified at language implementation time.
d.The location in memory of a global static variable: Compile time -> Higher to lower level construct mapping and memoey assignment of static code, type checking etc is done at compile time. So global static variable would be allocated memory at compile time.
e.The code for the printf function: Linking time->functiona call binding to their code is done at linking time. So printf function code would be binded at linking time.
f.The type of a local variable in a function: Compile time -> Higher to lower level construct mapping and memoey assignment of static code, type checking etc is done at compile time. So type of the local variable would be checked at compile time.
g.The value(s) assigned to a variable: Runtime -> values to variables and virtual function, object creation etc is done at runtime.
h.The size in memory of a pointer: Compile time -> Higher to lower level construct mapping and memoey assignment of static code is done at compile time. Local variable memory is assigned in runtime stack. So pointer memory will also be assigned in the runtime stack. As pointer store the address of the data, we should know the address of the data before storing. So Pointer's size is important and should be known at compile time, inorder to store the value at runtime.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.