Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Iterators Create a class Food that has the name of a food, calories, and serving size. Your Food class does not need to be

C++ Iterators

Create a class Food that has the name of a food, calories, and serving size. Your Food class does not need to be templated.

Using the STL List, create a list of favorite foods using your Food class, then create an iterator that you used to display the list with a function. Use the STL algorithm library to find items on the list, sort the list, count some specific item on the list.

Then use the decrement operator on your iterator to navigate from one place on your list to another.

Using the decrement operator start at the bottom of your list to work up to the top, displaying your entries. Use the begin/end methods for list for your iterator.

Hint:

Think about what youll have to do to your class to take advantage of the STL containers and functions.

For printing the list with the iterator, its not as straightforward as printing from begin to end.

Youll have to set your iterator to end and decrement it before starting the print. Youll need to use not equal (!=) with begin to stop, and then print the top of the list outside your loop.

Submit your .cpp, .h and main

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Creating A Database In Filemaker Pro Visual QuickProject Guide

Authors: Steven A. Schwartz

1st Edition

0321321219, 978-0321321213

More Books

Students also viewed these Databases questions