1. Where does the allocaters are used?
a) Allocation of memory
b) Deallocation of memory
c) Used for pointers
d) Both a & b
2. Where does the allocaters are implemented?
a) Template library
b) Standard library
c) C++ code library
d) None of the mentioned
3. Which operator is used to allocate the memory?
a) =
b) +
c) new
d) free
4. What is the output of this program?
a) 1 5 5 4
b) 5 5 4 1
c) 1 4 5 5
d) 1 4 5 2
5. What is the output of this program?
a) steve
b) jobs
c) jobs steve
d) steve jobs
6. What is the output of this program?
a) Hai
b) HaiHai
c) HaiHaiHai
d) None of the mentioned
7. Which operator is used to deallocate the memory?
a) destroy
b) free
c) empty
d) None of the mentioned
8. Which header file is used to manipulate the allocater?
a) allocater
b) memory
c) object
d) None of the mentioned
9. What is the use of reference member type in allocator?
a) Point to an element
b) Quantities of element
c) Reference to an element
d) None of the mentioned
10. What is the correct syntax for declaring an allocator?
a) template < class T > class allocator;
b) template < class T > class;
c) template class allocator;
d) None of the mentioned
a) Allocation of memory
b) Deallocation of memory
c) Used for pointers
d) Both a & b
2. Where does the allocaters are implemented?
a) Template library
b) Standard library
c) C++ code library
d) None of the mentioned
3. Which operator is used to allocate the memory?
a) =
b) +
c) new
d) free
4. What is the output of this program?
#include <iostream>
#include <memory>
#include <algorithm>
using namespace std;
int main ()
{
int numbers[] = {1, 5, 4, 5};
pair <int*, ptrdiff_t> result = get_temporary_buffer<int>(4);
if (result.second > 0)
{
uninitialized_copy (numbers, numbers + result.second, result.first);
sort (result.first, result.first + result.second);
for (int i = 0; i < result.second; i++)
cout << result.first[i] << " ";
return_temporary_buffer (result.first);
}
return 0;
}
b) 5 5 4 1
c) 1 4 5 5
d) 1 4 5 2
5. What is the output of this program?
#include <iostream>
#include <memory>
#include <string>
using namespace std;
int main ()
{
string numbers[] = {"steve", "jobs"};
pair <string*, ptrdiff_t> result = get_temporary_buffer<string>(2);
if (result.second>0)
{
uninitialized_copy ( numbers, numbers + result.second, result.first );
for (int i = 0; i < result.second; i++)
cout << result.first[i] << " ";
return_temporary_buffer(result.first);
}
return 0;
}
b) jobs
c) jobs steve
d) steve jobs
6. What is the output of this program?
#include <iostream>
#include <memory>
#include <string>
using namespace std;
int main ()
{
pair <string*, ptrdiff_t>
result = get_temporary_buffer<string>(3);
if (result.second > 0)
{
uninitialized_fill ( result.first, result.first + result.second,
"Hai" );
for (int i=0; i<result.second; i++)
cout << result.first[i] ;
return_temporary_buffer(result.first);
}
return 0;
}
b) HaiHai
c) HaiHaiHai
d) None of the mentioned
7. Which operator is used to deallocate the memory?
a) destroy
b) free
c) empty
d) None of the mentioned
8. Which header file is used to manipulate the allocater?
a) allocater
b) memory
c) object
d) None of the mentioned
9. What is the use of reference member type in allocator?
a) Point to an element
b) Quantities of element
c) Reference to an element
d) None of the mentioned
10. What is the correct syntax for declaring an allocator?
a) template < class T > class allocator;
b) template < class T > class;
c) template class allocator;
d) None of the mentioned