Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class Obiekt{
- };
- class Stos
- {
- private:
- Obiekt** stos;
- int count;
- int rozmiar;
- public:
- Stos(int);
- void push(Obiekt*);
- Obiekt* pop();
- };
- void Stos::push(Obiekt* obiekt) {
- if(count + 1 > rozmiar) {
- return;
- }
- stos[count] = obiekt;
- count++;
- }
- Obiekt* Stos::pop() {
- if(count == 0) {
- return NULL;
- }
- Obiekt* temp = stos[count]; count--;
- return temp;
- }
- Stos::Stos(int rozmiar) {
- count = 0;
- this->rozmiar = rozmiar;
- stos = new Obiekt*[rozmiar];
- }
- int main() {
- Obiekt* obiekt1 = new Obiekt();
- Obiekt* obiekt2 = new Obiekt();
- Obiekt* obiekt3 = new Obiekt();
- Stos stos(50);
- stos.push(obiekt1);
- stos.push(obiekt2);
- stos.push(obiekt3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement