rendered paste body/* Single stack example *//* first steps in classes and data structures */#include <iostream>#include <cstdlib>using namespace std;class stack { struct node { int data; node * next; }; node *p; public: stack() { p = NULL;}; /* class methods */ int pop(); void push(int d); int delsearch(int d); void print(); friend stack operator+(const stack & a,const stack & b); };int stack::pop () { node * tmp = p; int d; d = p->data; p = p->next; free(tmp); return d; }void stack::push(int d) { node * tmp; tmp = (node * ) malloc(sizeof(node)); if (tmp) { tmp->data = d; tmp->next = p; p = tmp; } }int stack::delsearch(int d) { node *tmp = p; int _tmp; while (tmp && tmp->data != d) tmp = tmp->next; if (tmp->data == d) { node *t = p; _tmp = t->data; t->data = d; tmp->data = _tmp; pop(); } }void stack::print() { while (p) { cout << p->data << endl; p = p->next; } }stack operator+(const stack & a,const stack & b) { stack tmp = a, t = b; while (t.p) { tmp.push(t.pop()); } return stack(tmp); }/* main program */int main(int argc, char *argv[]){ stack s, b, c; s.push(10); // just example b.push(12); c = s + b; c.print(); return EXIT_SUCCESS;}