InterviewSolution
| 1. |
How Do You Use The Stl? |
|
Answer» By including the necessary header files to permit ACCESS to the parts of the STL that you need, by declaring objects of the appropriate container, ITERATOR and function types, and then USING member functions and/or algorithms, as appropriate, to PERFORM whatever tasks your application requires. It is also generally necessary to ensure that whatever objects you plan to put into your container(s) are objects of classes that have a default constructor, a copy constructor, and an overloaded operator=. In addition, if you plan to sort or compare such container objects, the corresponding classes must provide definitions for operator== and operator<. FINALLY, since it is often the case that different containers can be used in the same problem situation, the user needs to be able to make an appropriate choice for each occasion, and this choice will usually be based on performance characteristics. By including the necessary header files to permit access to the parts of the STL that you need, by declaring objects of the appropriate container, iterator and function types, and then using member functions and/or algorithms, as appropriate, to perform whatever tasks your application requires. It is also generally necessary to ensure that whatever objects you plan to put into your container(s) are objects of classes that have a default constructor, a copy constructor, and an overloaded operator=. In addition, if you plan to sort or compare such container objects, the corresponding classes must provide definitions for operator== and operator<. Finally, since it is often the case that different containers can be used in the same problem situation, the user needs to be able to make an appropriate choice for each occasion, and this choice will usually be based on performance characteristics. |
|