C++ Interview Question and Answers
41. |
What is a container class? What are the types of container classes? |
|
- A container class is a class that is used to hold objects in memory or external storage.
- A container class acts as a generic holder.
- A container class has a predefined behavior and a wellknown interface.
- A container class is a supporting class whose purpose is to hide the topology used for maintaining the list of objects in memory.
- When a container class contains a group of mixed objects, the container is called a heterogeneous container; when the container is holding a group of objects that are all the same, the container is called a homogeneous container.
|
|
|
42. |
What is Associative container? |
|
Associative containers are designed to support direct access to elements using keys. They are not sequential. There are four types of associatives containers :- Set
- Multiset
- Map
- Multimap
|
|
|
43. |
What is an iterator? |
|
Iterators are like pointers. They are used to access the elements of containers thus providing a link between algorithms and containers. Iterators are defined for specific containers and used as arguments to algorithms. |
|
|
44. |
What are the defining traits of an object-oriented language? |
|
The defining traits of an object-oriented langauge are : - Encapsulation
- Inheritance
- Polymorphism
|
|
|
45. |
What is this pointer? |
|
It is a pointer that points to the current object. This can be used to access the members of the current object with the help of the arrow operator. |
|
|