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

Posted by Wendell on Jul 02, 2026 at 08:18 PM

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;

}

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

Get Premium CPP Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
21 comments · newest first
LA
Lavelle 5 days ago
Agreed, line I is fine.
LO
Louisa 10 days ago
I think line I is correct. Simple initialization.
SU
Suzan 15 days ago
Yes, those look correct to me.
TA
Tasia 20 days ago
So, A, B, D, and E?
LE
Lettie 25 days ago
True, line V is good. All options are valid.
CY
Cyril 1 month ago
Line V is also valid. Vector works well.
SU
Suzan 1 month ago
I feel line IV is correct. It’s valid syntax.
TA
Tasia 1 month ago
Line IV is tricky. List as a container?
LE
Lettie 2 months ago
Line II is good, but what about line IV?
CY
Cyril 2 months ago
Line II seems fine too. Using deque is okay.
SU
Suzan 2 months ago
Agreed, line I is definitely valid.
TA
Tasia 2 months ago
I think line I is correct. Simple initialization.
TE
Terrilyn 2 months ago
I thought stacks could only use specific containers, not just any!
RA
Raul 2 months ago
Line IV is correct, but Line V seems off to me.
ST
Stevie 3 months ago
Wait, can you really initialize a stack with a deque?
LA
Lashanda 3 months ago
I think Line II is valid too!
GO
Golda 3 months ago
Line I is definitely correct.
PA
Paola 3 months 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.
LA
Laurel 3 months 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.
MA
Maile 3 months ago
I think line I is definitely correct since it’s just a basic stack initialization.
LE
Lea 4 months ago
I remember that stacks can be initialized with different containers, but I'm not sure if all these initializations are valid.
0/2000 characters

Save Cancel