Default constructor for a stack

I am currently working on a project for class that requires us to implement a stack for integer use as a calculator. I am having problems with my default constructor and am wondering what I am missing.

1
2
3
4
5
6
7
8
  OperandStack(int stackSize)
	{
		if (stackSize<=0)
			{cout<<"Must be positive"<<endl;}
		this->capacity=capacity;
		s =new double[stackSize];
		t=0;
	}


Thank you for your assistance.
this->capacity=capacity; What do you think this line is doing?
Shouldn't it be this->capacity = stackSize;?

Also prefer to make errorneous data impossible to pass and use member init lists.

1
2
OperandStack(std::size_t stackSize) : capacity(stackSize), s(new double[stackSize]), t(0) : 
{}
Topic archived. No new replies allowed.