Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given two classes, one being an array-based stack, and another being a iterator for that array-based stack. How could you overload the dereference operator(*)? Here

Given two classes, one being an array-based stack, and another being a iterator for that array-based stack. How could you overload the dereference operator(*)?

Here is the class declaration:

template class StackIterator { public: StackIterator(); //Default constructor StackIterator(stackType *new_ptr); //Constructor with a parameter. Type operator*(); StackIterator operator++(); bool operator==(const StackIterator& right) const; bool operator!=(const StackIterator& right) const;

private: stackType *ptr; //pointer to act as iterator for array stack };

Here is what I have so far, but I get an error saying that "stackType cannot convert to "

template Type StackIterator::operator*() { return *ptr; }

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

10:16 AM Sun Jan 29 Answered: 1 week ago

Answered: 1 week ago