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 CPP Exam - Topic 2 Question 126 Discussion

Which stack initialization (line numbers) are correct? Choose all that apply.#include #include #include #include #include using namespace std;int main(){deque mydeck;list mylist;vector myvector;stack first;// Line Istack second(mydeck);// Line IIstack third(second);// Line IIIstack fourth(mylist);// Line IVstack fifth(myvector);// Line Vreturn 0;}
A) line I and B) line II and C) line III and D) line IV and E) line V

C++ Institute CPP Exam - Topic 2 Question 126 Discussion

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

Which stack initialization (line numbers) are correct? Choose all that apply.

#include

#include

#include

#include

#include

using namespace std;

int main()

{

deque mydeck;

list mylist;

vector myvector;

stack first;// Line I

stack second(mydeck);// Line II

stack third(second);// Line III

stack > fourth(mylist);// Line IV

stack > fifth(myvector);// Line V

return 0;

}

Show Suggested Answer Hide Answer
Suggested Answer: A, B, C, D, E

Contribute your Thoughts:

0/2000 characters
Terrilyn
2 days ago
I thought stacks could only use specific containers, not just any!
upvoted 0 times
...
Raul
8 days ago
Line IV is correct, but Line V seems off to me.
upvoted 0 times
...
Stevie
13 days ago
Wait, can you really initialize a stack with a deque?
upvoted 0 times
...
Lashanda
18 days ago
I think Line II is valid too!
upvoted 0 times
...
Golda
23 days ago
Line I is definitely correct.
upvoted 0 times
...
Paola
28 days ago
I practiced a similar question, and I think line IV is valid since it uses a list as the underlying container for the stack.
upvoted 0 times
...
Laurel
1 month ago
Line II seems tricky; I feel like it should work, but I can't recall if stacks can be directly initialized with a deque.
upvoted 0 times
...
Maile
1 month ago
I think line I is definitely correct since it’s just a basic stack initialization.
upvoted 0 times
...
Lea
1 month ago
I remember that stacks can be initialized with different containers, but I'm not sure if all these initializations are valid.
upvoted 0 times
...

Save Cancel