Set - 3

Question 11 :

What is a class?

Answer :

Class is a user-defined data type in C++. It can be created to solve a particular kind of problem. After creation the user need not know the specifics of the working of a class.


Question 12 :

What is friend function?

Answer :

As the name suggests, the function acts as a friend to a class. As a friend of a class, it can access its private and protected members. A friend function is not a member of the class. But it must be listed in the class definition.


Question 13 :

Which recursive sorting technique always makes recursive calls to sort subarrays that are about half size of the original array? 

Answer :

Mergesort always makes recursive calls to sort subarrays that are about half size of the original array, resulting in O(n log n) time.


Question 14 :

What is abstraction?

Answer :

Abstraction is of the process of hiding unwanted details from the user.


Question 15 :

What are virtual functions? 

Answer :

A virtual function allows derived classes to replace the implementation provided by the base class. The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class, even if the object is accessed by a base pointer rather than a derived pointer. This allows algorithms in the base class to be replaced in the derived class, even if users don't know about the derived class.