简体   繁体   中英

Any Garbage value in STL stack in c++?

stack<int> s;
while(!s.empty()) s.pop;

I saw this in a book before using a STL stack. this means if the stack holds any value this will be popped out. but when I used a stack.I saw it don't hold any value after declaration. Is there any possibility to hold any garbage value after declaration of STL stack?

To simply answer your question, basically once you declare a stack it is not initialized with garbage values. (It is good practice to initialize stuff in general though)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM