commit fc2ebfb72c3b21be29a150e267274f7b1ce97433 parent ccafde8142524a448c77cd229d1c2657fa2d1fca Author: Agastya Chandrakant <acagastya@outlook.com> Date: Fri, 3 Nov 2017 10:38:01 +0530 Delete tq2.cpp Diffstat:
D | s3/oops/tq2.cpp | | | 63 | --------------------------------------------------------------- |
1 file changed, 0 insertions(+), 63 deletions(-)
diff --git a/s3/oops/tq2.cpp b/s3/oops/tq2.cpp @@ -1,63 +0,0 @@ -#include <iostream> -#define MAX 5 - -int read = -1; -int write = -1; - -class queue{ -template <class T> - T data[MAX]; -public: -template <class T> - void inQueue(){ - T incoming; - if(write == MAX - 1){ - std::cout << "Queue overflow\n"; - return; - } - if(read == -1) - ++read; - std::cout << "Enter element to be entered: "; - std::cin >> incoming; - write = (write + 1); - data[write] = incoming; - }; - template <class T> - void deQueue(){ - if(read == -1 || read > write) - std::cout << "Queue underflow.\n"; - else{ - std::cout << data[read] << " has been removed.\n"; - read++; - } - }; - template <class T> - void displayQueue(){ - if(write == -1 || read > write) - std::cout <<"Queue is empty.\n"; - else{ - for(int i = read; i <= write; i++) - std::cout << data[i] << " "; - std::cout << "\n"; - } - }; -}; - -int main() { - int choice; - queue <int> q; - do{ - std::cout << "Enter choice: "; - std::cin >> choice; - switch (choice) { - case 1: q.inQueue(); - q.displayQueue(); - break; - case 2: q.deQueue(); - q.displayQueue(); - break; - default: choice = 0; - } - }while(choice); - return 0; -}