Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <string>
- using namespace std;
- template <class T>
- class Stos {
- public:
- int size;
- T *stos;
- int ptr;
- Stos() {
- size = 10;
- stos = new T[size];
- ptr = 0;
- }
- ~Stos() {
- }
- void push(T x) {
- stos[ptr] = x;
- ptr++;
- }
- T* pop(void) {
- ptr--;
- return stos + ptr;
- }
- };
- int main(void) {
- Stos <string> s1;
- s1.push("Oto");
- s1.push("jest");
- s1.push("stos.");
- cout<< endl;
- cout << *s1.pop() << " " << *s1.pop() << " " << *s1.pop() << endl << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement