I want to push a value to a stack using the assignment operator, I need some help with this.. Thanks
Stack s;
float x = 5;
s = x;
class Stack
{
public:
Stack();
float push(float value);
float pop();
int Size();
float operator = (const float &right);
private:
float values[30];
int top;
int size;
};
float Stack::push(float value)
{
top++;
size++;
values[top] = value;
return value;
}
float Stack::pop()
{
size--;
return values[top--];
}
int Stack::Size()
{
return size;
}
float Stack::operator= (const float &right)
{
float temp_val = right;
Stack temp;
return temp.push(temp_val);
}