0
what is the output of this program??
#include<iostream> #include<stack> using namespace std; int main() { stack<int> s; s.push(1); s.push(2); s.empty(); s.push(3); cout<< s.size(); }
2 Antworten
0
The output is 3. If you're asking WHY it outputs 3, the empty function does not empty the stack; it return 1 if it's empty and 0 if it's not. Thus, after pushing 3 numbers into the stack, the size of the stack is 3 and outputs 3.