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...
icon
Related questions
Question
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 <iostream>
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;
====
====
Transcribed Image Text: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 <iostream> 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 <iostream>
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;
}
}
Transcribed Image Text:#include <iostream> 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; } }
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning