C++ Interview Question and Answers

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.
 
Karthik,says July 12,2017
One of the methods is, we can create a replica of the same class, cast the other class to the replicated and access it.
Your Name Your Email-ID
Your Answer
122. What do you mean by late binding?
 
  • Late binding refers to function calls that are not resolved until run time.
  • Virtual functions are used to achieve late binding.
  • 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.
 
Your Name Your Email-ID
Your Answer
123. What do you mean by early binding?
 
  • Early binding refers to the events that occur at compile time.
  • Early binding occurs when all information needed to call a function is known at compile time.
  • Examples of early binding include normal function calls, overloaded function calls, and overloaded operators.
  • The advantage of early binding is efficiency.
 
Your Name Your Email-ID
Your Answer