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:

Malcom
16 days ago
I'm pretty sure all the other lines are valid instantiations. Line IV is the only one that doesn't work. Now, if they asked me to instantiate a priority_queue with a banana, that would be a different story!
upvoted 0 times
...
Cyril
1 months ago
Haha, it's funny how they try to trick us with a list. Who uses a list for a priority queue? That's like trying to use a toaster to dry your hair!
upvoted 0 times
Paris
1 days ago
I agree, a list is not efficient for a priority queue.
upvoted 0 times
...
Irma
8 days ago
Definitely! A priority queue should be implemented with a deque or a vector.
upvoted 0 times
...
Buck
9 days ago
Haha, I know right! Using a list for a priority queue is a bad idea.
upvoted 0 times
...
Pamela
13 days ago
B) line II
upvoted 0 times
...
Lyda
16 days ago
A) line I
upvoted 0 times
...
...
Carissa
2 months 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
2 months ago
I agree with Van, line I is incorrect because it is missing the container type.
upvoted 0 times
...
Van
2 months ago
I think line I is not a valid instantiation.
upvoted 0 times
...
Maynard
2 months 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
Cecily
2 days ago
That makes sense. Thanks for clarifying!
upvoted 0 times
...
Sherrell
26 days ago
So, the correct answer would be D) line IV.
upvoted 0 times
...
Beckie
1 months ago
Yes, I agree. The correct containers for priority_queue are deque and vector.
upvoted 0 times
...
Marget
1 months ago
I think line IV is not valid because list is not a valid container for priority_queue.
upvoted 0 times
...
...
Carmela
2 months 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
2 months ago
I agree with Willetta, line I is incorrect because it is missing the container type.
upvoted 0 times
...
Mabel
2 months 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
2 months ago
I think line I is not a valid instantiation.
upvoted 0 times
...

Save Cancel