Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Urgently ask a C++ program to write a class to realize the simplest stack. The stack data member consists of 10 plastic arrays, and the following operations are performed successively:
Urgently ask a C++ program to write a class to realize the simplest stack. The stack data member consists of 10 plastic arrays, and the following operations are performed successively:
Class stack

{

Int value [10];

Public:

int pos

Boolean pique (int& value);

Bool push(int value);

Boolean popularity (int& value);

Invalid reset ()

{

pos = 0;

}

Stack ()

{

pos = 0;

}

}

Bool stack: peek (int&; Value)

{

If (position ==0)

{

Returns false

}

Value = value [pos-1];

retuan true

}

Boolean stack: push(int value)

{

if(pos== 10)

{

Returns false

}

values[pos++]= value;

Return true

}

Bool stack: pop(int & amp; Value)

{

If (position ==0)

{

Returns false

}

Value = value [-position];

retuan true

void main()

{

Int value;

Stack stack;

stack . push( 12);

if(stack.peek(value))

Printf("%d ",value);

if(stack.pop(value))

Printf("%d ",value);

}

It's written by mobile phone, which is enough for you to solve the problem.