1. Explain what a base class access specifier is and how it affects inheritance.
ID: 3558675 • Letter: 1
Question
1. Explain what a base class access specifier is and how it affects inheritance.
2. Define what is meant by the term compile-time binding, and list two other terms that are also used to describe it. Explain why compile-time binding can present problems when implementing polymorphism in a program.
3. Describe what a namespace is, and provide the general syntax of a namespace statement.
4. Write the code that will declare an integer array of dimension 10 and then use pointer arithmetic to initialize all the elements of that array to zero. Comment on each line of code to describe what that line does.
Explanation / Answer
1
base class specifier can be publci private or protected.
depending upon specifier
derived calss get access to memeber of base class
2
Binding :
Binding means asociating the values to symbols in the program code. There are two type compile time ( Static !) and runtime (synamic)
Compile time bindings are done at compile time, thus all the symbols are resolved at compile time, This increases the compile time thugh u can see some run time performance increases ( generally its the load time). Here things are static and the code generated by compiler is ready to load at a relative memory area and the start executing.
runtime binding or dynamic binding, where the bindings are delayed to load time or run time. the symbols will be resolved at load time or run time so that the extern declarations and other external linking can be allowed. This may add small extra time in execution of the progrm ( May be loading ).
3
Namespaces allow to group entities like classes, objects and functions under a name. This way the global scope can be divided in "sub-scopes", each one with its own name.
The format of namespaces is:
namespace identifier
{
entities
}
Where identifier is any valid identifier and entities is the set of classes, objects and functions that are included within the namespace. For example:
In this case, the variables a and b are normal variables declared within a namespace called myNamespace. In order to access these variables from outside the myNamespace namespace we have to use the scope operator :
4
int arr[10];//declare array;
for(int i=0;i<10;i++){ //loop 10 times
*(arr+i)=0; //set arr[i]= 0 where i is i int in memory after arr
}
1 2 3 4
namespace myNamespace { int a, b; } Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.