This stack program runs correctly for given array size arr[5] or arr[10].But when i take size as input from the user cin>>n it says "Error: ‘cin’ does not name a type."
Here is that code:
#include <iostream>
using namespace std;
class Stack
{
private:
int n;
cin>>n;
int arr[n];
int top=-1;
public:
rest of the code
So i tried to take a random input for size of array but got this error when used cin to take input. I have used namespace std but still got the error Error: ‘cin’ does not name a type.
It's my first time asking question in stack overflow so ask me if you need more clarification.