Interview Questions C++

C++


121. How can we access protected and private members of a class?
In the case of members protected and private, these could not be accessed from outside the same class at which they are declared. This rule can be transgressed with the use of the friend keyword in a class, so we can allow an external function to gain access to the protected and private members of a class.

122. What do you mean by late binding?
a. Late binding refers to function calls that are not resolved until run time.
b. Virtual functions are used to achieve late binding.
c. When access is via a base pointer or reference, the virtual function actually called is determined by the type of object pointed to by the pointer.

123. What do you mean by early binding?
a. Early binding refers to the events that occur at compile time.
b. Early binding occurs when all information needed to call a function is known at compile time.
c. Examples of early binding include normal function calls, overloaded function calls, and overloaded operators.
d. The advantage of early binding is efficiency.