Questions and Answers
- What do container adapter provide to interface?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
A container adapter provides a restricted interface to a container.In particular, adapters do not provide iterators; they are intended to be used only through their specialized interfaces.
- Which of the following does not support any insertion or deletion?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Because array is not dynamic in nature, So they can’t be manipulated.
- How the list containers are implemented?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
List containers are implemented as doubly-linked lists. Doubly linked lists can store each of the elements they contain in different and unrelated storage locations.
- What is the output of this program?
#include <iostream>
#include <cmath>
#include <list>
using namespace std;
bool IntegralPart(double One, double Two)
{
return ( int(One) == int(Two) );
}
struct is_near
{
bool operator() (double One, double Two)
{
return (fabs(One - Two) < 5.0);
}
};
int main ()
{
double Array[] = { 10.05, 3.70, 12.02, 10.25, 14.24, 11.47, 76.32, 82.35, 95.31, 52.95 };
list<double> ListData(Array, Array + 8);
ListData.sort();
ListData.unique();
ListData.unique (IntegralPart);
ListData.unique (is_near());
for (list<double> :: iterator iter = ListData.begin(); iter != ListData.end(); ++iter)
cout << ' ' << *iter;
cout << '\n';
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
In this program, We are eliminating the values by using the unique operation in the list.
- What is the output of this program?
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector<int> VectorData;
int * ptr;
unsigned int k;
ptr = VectorData.get_allocator().allocate(6);
for (k = 0; k < 6; k++)
VectorData.get_allocator().construct(&ptr[k], k);
for (k = 0; k < 6; k++)
cout << ' ' << ptr[k];
for (k = 0; k < 6; k++)
VectorData.get_allocator().destroy(&ptr[k]);
VectorData.get_allocator().deallocate(ptr, 6);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
In this program, We allocated the values to the vector by using get allocater and then we are destroying it.