Independence Day Deal! Unlock 25% OFF Today – Limited-Time Offer - 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
1 months 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
2 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
Eun
9 days ago
It's like using a toaster to dry your hair, totally useless!
upvoted 0 times
...
Lavonne
11 days ago
C) line III
upvoted 0 times
...
Paris
16 days ago
I agree, a list is not efficient for a priority queue.
upvoted 0 times
...
Irma
23 days ago
Definitely! A priority queue should be implemented with a deque or a vector.
upvoted 0 times
...
Buck
24 days ago
Haha, I know right! Using a list for a priority queue is a bad idea.
upvoted 0 times
...
Pamela
28 days ago
B) line II
upvoted 0 times
...
Lyda
1 months 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
17 days ago
That makes sense. Thanks for clarifying!
upvoted 0 times
...
Sherrell
1 months ago
So, the correct answer would be D) line IV.
upvoted 0 times
...
Beckie
2 months ago
Yes, I agree. The correct containers for priority_queue are deque and vector.
upvoted 0 times
...
Marget
2 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
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77