LogiQuest
Back to Templates
11

What will be the output of the program?

#include <iostream>
using namespace std;
template <typename T>
struct Stack {
    T d[10]; int top = 0;
    void push(T v) { d[top++] = v; }
    T pop() { return d[--top]; }
};
int main() {
    Stack<int> s;
    s.push(4); s.push(9);
    cout << s.pop() << s.pop() << endl;
    return 0;
}
Medium

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.