Interview Questions C++

C++


51. What do you mean by implicit conversion?
a. Whenever data types are mixed in an expression then c++ performs the conversion automatically.
b. Here smaller type is converted to wider type.
c. Example: in case of integer and float integer is converted into float type.

52. What are virtual functions?
a. The virtual functions must be members of some class.
b. They cannot be static members.
c. They are accessed by using object pointers.
d. A virtual function can be a friend of another class.

53. What is the main purpose of overloading operators?
a. The main purpose of operator overloading is to minimize the chances of occurance of errors in a class that is using the overload operators.
b. It also helps in redefining the functionalities of the operators to improve their performance.
c. Operator overloading also makes the program clearer, readable and more understandable by using common operators, such as +, =, and [].

54. What is a friend?
Friends can be either functions or other classes. The class grants friends unlimited access privileges.

55. What is stack unwinding?
Stack unwinding is a process in which a destructor is invoked in a particular program for destroying all the local objects in the stack between throwing and catching of an exception.

56. What is the difference between class and structure?
a. By default, the members to structures are public while that tor class is private.
b. Structures don't provide something like data hiding which is provided by the classes.
c. Structures contain only data while classes bind both data and member functions.

57. What are storage qualifiers in C++?
ConstKeyword indicates that memory once initialized, should not be altered by a program.
Volatile keyword indicates that the value in the memory location can be altered even though nothing in the program.
Mutable keyword indicates that particular member of a structure or class can be altered even if a particular structure variable, class, or class member function is constant.

58. What is virtual class and friend class?
Friend classes are used when two or more classes and virtual base class aids in multiple inheritance.
Virtual class is used for run time polymorphism when object is linked to procedure call at run time.

59. What is an abstract base class?
An abstract class is a class that is designed to be specifically used as a base class. An abstract class contains at least one pure virtual function.

60. What is dynamic binding?
Dynamic binding (also known as late binding) means that the code associated with a given procedure call is not known until the time of the call at run time.It is associated with polymorphism and inheritance.