Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by Stouf ( 14 years ago )
#include <iostream.h>
using namespace std;

class Stos
{
      private:
              int *tab;
              int w;
      public;
      void push(int element);
      int pop();
      void wyswietl();
      
      Stos()
      {
       tab = new int[100];
       w = 0;
      }
       
      ~Stos() { delete [] tab;)
      
};

void Stos::push(int element)
{
     if(w < 100 )
     {
          tab[w++] = element;
          cout << "Odlozono element "<<tab[w-1]<<" na stos"<<endl;
     }
}

int Stos::pop()
{
 cout << "Zdejmujemy element " << tab[w-1] << endl;
 w--;
}

void Stos::wyswietl()
{
     for(int i=0; i<w; i++)
     cout << tab[i] << endl;
}

int main()
{
    Stos s;
    s.push(1);
    s.push(2);
    s.push(4);
    s.push(8);
    s.push(16);
    s.push(32);
    s.wyswietl();
    s.pop();
    s.wyswietl();
    getchar();
    system&#40;"PAUSE"&#41;;

 

Revise this Paste

Your Name: Code Language: