Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!