Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute Exam CPP Topic 2 Question 77 Discussion

Actual exam question for C++ Institute's CPP exam
Question #: 77
Topic #: 2
[All CPP Questions]

Which are NOT valid instantiations of priority_queue object:

#include

#include

#include

#include

#include

using namespace std;

int main()

{

deque mydeck;list mylist; vector myvector;

priority_queue first;//line I

priority_queue > second;//line II

priority_queue third(first);//line III

priority_queue > fourth(third);//line IV

priority_queue > fifth(myvector.begin(), myvector.end());//line V

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: E

Contribute your Thoughts:

Carissa
2 days ago
I believe line V is also not valid because it is trying to initialize a priority_queue with iterators from a vector.
upvoted 0 times
...
Lauran
3 days ago
I agree with Van, line I is incorrect because it is missing the container type.
upvoted 0 times
...
Van
4 days ago
I think line I is not a valid instantiation.
upvoted 0 times
...
Maynard
6 days ago
I agree with Mabel. The list is not a valid container for a priority_queue, so line IV is not a valid instantiation.
upvoted 0 times
...
Carmela
6 days ago
I believe line V is also not valid because it is trying to initialize a priority_queue with iterators from a vector.
upvoted 0 times
...
Darrin
7 days ago
I agree with Willetta, line I is incorrect because it is missing the container type.
upvoted 0 times
...
Mabel
7 days ago
The correct answer is line IV. A priority_queue can only be instantiated with a deque or a vector as the underlying container, not a list.
upvoted 0 times
...
Willetta
8 days ago
I think line I is not a valid instantiation.
upvoted 0 times
...

Save Cancel