Stack

....
Last edited on
line 11: max must be known at compile time.
Any idea how would that look like in the code?
Last edited on
1
2
//  After line 6
static const int max = 50;  // Or whatever max size you want 


Note: std::vector is safer to use than a raw array.

note: You won't be able to do a cin to max here. If you want to prompt the user for some number of values to put on the stack, use a different variable.

Thank you for the fast reply. I am just using max for user to set the max amount of "space" in stack. And I do not know how to make user in line 54: to enter the value. And I am aware that cin >> max is not the right method but I have no idea how to make it for user to change. How do I connect different variable with global max variable. Thank you so much for help and fast replying.
As I suggested above, std::vector is safer to use. A std::vector has no explicit limit on the number of entries and keeps track of the number of entries automatically.
Topic archived. No new replies allowed.