Question
In C++ Need to add an iterator, and the main functions. I believe that you need to add five functions and nested class definition. Please
In C++
Need to add an iterator, and the main functions. I believe that you need to add five functions and nested class definition. Please fulfill out the code without changing anything that is posted below and explain why you picked those functions and how the nested class definition with the iterator work. Please show output that you have received.
// GoFIterator.h #ifndef GOF_ITERATOR_H #define GOF_ITERATOR_H class GoFIterator { public: virtual void first() = 0; virtual void next() = 0; virtual bool isDone() = 0; virtual int currentItem() = 0; }; #endif // GOF_ITERATOR_H // IntegerBuffer.h #ifndef INTEGER_BUFFER_H #define INTEGER_BUFFER_H #include "GoFIterator.h" class IntegerBuffer { private: int data[32]; int dataLength = 0; int dataCapacity = 32; public: bool add(int value); int add(int* values, int numValues); }; #endif // INTEGER_BUFFER_H // IntegerBuffer.cpp #include "IntegerBuffer.h" bool IntegerBuffer::add(int value) { if (dataLength < dataCapacity) { data[dataLength] = value; ++dataLength; return true; } else return false; } int IntegerBuffer::add(int values[], int numValues) { int count = 0; for (int i = 0; i < numValues; ++i) if (add(values[i])) ++count; return count; }
// testHW2.cpp #include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started