Problem of checking Compile errors Runtime errors ======== } ng; } You have the following IQueue interface. Implement a Queue class derived from IQueue. You can use STL containers discussed in class, such as vector, queue, stack, deque, map. #include using namespace std; class IQueue { public: }; virtual void Enqueue(int val) virtual int Dequeue() = 0; virtual int Size() const = 0; int main() = 0; { Queue q; ===== } cout << q.Size() << endl; q. Enqueue(10); q.Enqueue(20); q. Enqueue(30); cout << q.Size() << endl; cout << q.Dequeue() << endl; cout << q.Size() << endl; cout << q.Dequeue() << endl; cout << q.Size() << endl; cout << q.Dequeue() << endl; cout << q.Size() << endl; ==== ==== #include using namespace std; class A { public: static int objcnt; A() { objcnt ++; } ~A() { objcnt --; } static int GetCount() { static int objcnt = 0; return objcnt; } }; int objcnt = 0; int A::objcnt = 0; int main() { cout << A::GetCount() << endl; { A a; cout << A::GetCount() << endl; cout << A::GetCount() << endl; } }
Problem of checking Compile errors Runtime errors ======== } ng; } You have the following IQueue interface. Implement a Queue class derived from IQueue. You can use STL containers discussed in class, such as vector, queue, stack, deque, map. #include using namespace std; class IQueue { public: }; virtual void Enqueue(int val) virtual int Dequeue() = 0; virtual int Size() const = 0; int main() = 0; { Queue q; ===== } cout << q.Size() << endl; q. Enqueue(10); q.Enqueue(20); q. Enqueue(30); cout << q.Size() << endl; cout << q.Dequeue() << endl; cout << q.Size() << endl; cout << q.Dequeue() << endl; cout << q.Size() << endl; cout << q.Dequeue() << endl; cout << q.Size() << endl; ==== ==== #include using namespace std; class A { public: static int objcnt; A() { objcnt ++; } ~A() { objcnt --; } static int GetCount() { static int objcnt = 0; return objcnt; } }; int objcnt = 0; int A::objcnt = 0; int main() { cout << A::GetCount() << endl; { A a; cout << A::GetCount() << endl; cout << A::GetCount() << endl; } }
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16PE:
The implementation of a queue in an array, as given in this chapter, uses the variable count to...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning