Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description: The concept of an iterator is fundamental to understanding the C++ Standard Template Library (STL). Iterators provide access to data stored in container classes

Description:

"The concept of an iterator is fundamental to understanding the C++ Standard Template Library (STL). Iterators provide access to data stored in container classes (e.g. vector, map, list, etc.)

Design and implement a C++ array container class that returns an iterator class used for accessing the array elements. Your iterators support begin and end functions along with overloaded not equal ("!="), dereferencing ("*"), post incrementing ("++"), and indexing ("[]") operators.

Use an iterator to access elements of the associated array class elements sequentially, elements that are prime and composite (non-prime) numbers, and elements who are the sum of the two previous elements (Fibonacci like.) Read integer values from a file into the array class, instantiate the appropriate iterator for the desired behavior, and then use the iterator to iterate thru the array values."

Lab requirements:

Command line argument #1 (argv[1]) points to the input file name.

Command line argument #2 (argv[2]} points to the output file name.

A template class of your making is used to contain a C++ array of numbers.

Memory for the array is malloc'd, the size specified in a constructor argument.

Numbers are stored in the array class using a push_back function.

The array class also contains a nested iterator class and begin() and end() public member functions that return instantiated iterator objects.

The array class begin() function is also overloaded such that the returned iterator can be used to access sequential, prime, composite (non-prime), and Fibonacci-like (element is equal to the sum of the previous two elements) elements.

The iterator class overloads the dereferencing ("*"), incrementing ("++"), not equal ("!="), and indexing ("[]") operators.

All classes (including the iterator) have public toString and friend insertion member functions.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions