Latest C++ Interview Questions and Answers Part-4
A function is overloaded when same name is given to different function.
While overloading a function, the return type of the functions need to be the same.
32. What are the advantages of inheritance?
Saves time in program development.
33. What is a dynamic constructor?
The constructor can also be used to allocate memory while creating objects.
Allocation of memory to objects at the time of their construction is known as dynamic construction of objects.
The memory is allocated with the help of the new operator.
34. What is the difference between an Array and a List?
The main difference between an array and a list is how they internally store the data. whereas Array is collection of homogeneous elements. List is collection of heterogeneous elements.
35. What is the use of ‘using’ declaration?
A using declaration makes it possible to use a name from a namespace.
36.What is the difference between a template class and class template?
Template classA generic definition or a parameterized class not instantiated until the client provides the needed information. It’s jargon for plain templates.
Class templateA class template specifies how individual classes can be constructed much like the way a class specifies how individual objects can be constructed. It’s jargon for plain classes.
37. What is friend function?
The function declaration should be preceded by the keyword friend.
The function definitions does not use either the keyword or the scope operator ::
The functions that are declared with the keyword friend as friend function.
Thus, a friend function is an ordinary function or a member of another class.
38. What is a scope resolution operator?
A scope resolution operator (::), can be used to define the member functions of a class outside the class.
39. What do you mean by pure virtual functions?
A pure virtual member function is a member function that the base class forces derived classes to provide. Any class containing any pure virtual function cannot be used to create object of its own type.
40. What is a conversion constructor?
A converting constructor is a single-parameter constructor that is declared without the function specifier explicit.
The compiler uses converting constructors to convert objects from the type of the first parameter to the type of the converting constructor’s class.