C++ , there are two questions, please chose the correct one 1. A class template
ID: 3766852 • Letter: C
Question
C++ , there are two questions, please chose the correct one
1. A class template
(a) may contain typename and size_t parameters in its declaration
(b) is generated from a class-template specialization at compilation time
(c) can not be overloaded with a non-template function
(d) none of the above
2. The failture of new in allocationg memory can be handled by
(a) catching the bad_alloc expception
(b) checking if the pointer returned by new is nullptr or not.
(c) using the set_new_handler() function
(d) all of the above
Explanation / Answer
=====================================================================
1. A class template
(a) may contain typename and size_t parameters in its declaration
(b) is generated from a class-template specialization at compilation time
(c) can not be overloaded with a non-template function
(d) none of the above
---------
Answer:
---------
(b) is generated from a class-template specialization at compilation time
---------
Explanation:
---------
A class template is generated from a class template specialization at compile time.
If any code errors are present at comipile are corrected to proceed the program to run.
Hence the option b is correct answer.
=====================================================================
2. The failture of new in allocationg memory can be handled by
(a) catching the bad_alloc expception
(b) checking if the pointer returned by new is nullptr or not.
(c) using the set_new_handler() function
(d) all of the above
---------
Answer:
---------
(d) all of the above
---------
Explanation:
---------
Failures of new keyword for allocating memory can be handled by all the mentioned ways.
i.e catching the bad_alloc expception using try/catch block. or checking if the pointer returned by new is nullptr or not.
or by using the set_new_handler() function. Hence all the above is the correct option.
=====================================================================
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.