BLACK FRIDAY SALE – Unlock Up to 25% OFF on All Exam Prep! - 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
28 comments · newest first
AN
Annabelle 14 days ago
No, line II is correct! All lines are valid.
OM
Omega 19 days ago
So, all lines are correct except line II?
YA
Yan 24 days ago
Line V is also correct. Vector is acceptable.
LE
Leigha 29 days ago
Line IV is valid. List can be used.
JO
Joaquin 1 month ago
Line III is good too. Copying stacks is allowed.
SH
Shawana 1 month ago
Yes, line II is correct. Deque works for stack.
JE
Jerry 1 month ago
Line II seems tricky. Is deque valid?
LA
Lavelle 2 months ago
Agreed, line I is fine.
LO
Louisa 2 months ago
I think line I is correct. Simple initialization.
SU
Suzan 2 months ago
Yes, those look correct to me.
TA
Tasia 2 months ago
So, A, B, D, and E?
LE
Lettie 2 months ago
True, line V is good. All options are valid.
CY
Cyril 3 months ago
Line V is also valid. Vector works well.
SU
Suzan 3 months ago
I feel line IV is correct. It’s valid syntax.
TA
Tasia 3 months ago
Line IV is tricky. List as a container?
LE
Lettie 3 months ago
Line II is good, but what about line IV?
CY
Cyril 3 months ago
Line II seems fine too. Using deque is okay.
SU
Suzan 3 months ago
Agreed, line I is definitely valid.
TA
Tasia 4 months ago
I think line I is correct. Simple initialization.
TE
Terrilyn 4 months ago
I thought stacks could only use specific containers, not just any!
RA
Raul 4 months ago
Line IV is correct, but Line V seems off to me.
ST
Stevie 4 months ago
Wait, can you really initialize a stack with a deque?
LA
Lashanda 4 months ago
I think Line II is valid too!
GO
Golda 4 months ago
Line I is definitely correct.
PA
Paola 5 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 5 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 5 months ago
I think line I is definitely correct since it’s just a basic stack initialization.
LE
Lea 5 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