Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3311880
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:55:43+00:00 2026-05-17T21:55:43+00:00

This isnt a homework question. I took data structures at a Community College and

  • 0

This isnt a homework question. I took data structures at a Community College and now that i am at the university i talked to the teacher about there data structures class. Now, since its really different and the class i took transferred, He gave me one of there assignments and said play with it. We never did any containers, wrappers,templates,..
So, i am a little lost, and i am trying to get up to speed on this. I am not new to linklist,queue,stack,circular arrays,trees,etc.. We just never did any of that ADT hierarchy with object, container.

I do not have a book on ADT hierarchy – container, object.. Can anyone recommend one. not sure what to look up? just ADT?

Here is my problem. I am trying to complete this code he gave me..
I am trying to write the function the operator ++ () = 0;
I am not sure about the syntax

#ifndef ITERATOR_H
#define ITERATOR_H
#include "Object.h"


class Iterator
{
public:
virtual ~Iterator ();
virtual void Reset () = 0;
virtual bool IsDone () const = 0;
virtual Object& operator * () const = 0;
virtual void operator ++ () = 0;
};

#endif

and here is the container header..

#ifndef CONTAINER_H
#define CONTAINER_H

#include <ostream>
#include "Object.h"
#include "Ownership.h"
#include "Iterator.h"
#include "Visitor.h"

class Container : public virtual Object, public virtual Ownership
{
protected:
unsigned int count;

Container ();
public:
virtual unsigned int Count () const;
virtual bool IsEmpty () const;
virtual bool IsFull () const;
//  virtual HashValue Hash () const;
virtual void Put (ostream&) const;
virtual Iterator& NewIterator () const;

virtual void Purge () = 0;
virtual void Accept (Visitor&) const = 0;
};

#endif

and here is the container.cpp file where i need help with the syntax for ++

#include <iostream>
#include "Container.h"

void Container::Purge()
{

if (IsOwner())

count = 0;

}

Container::Container () :
count (0)
{}

unsigned int Container::Count () const
{ return count; }

bool Container::IsEmpty () const
{ return Count () == 0; }

bool Container::IsFull () const
{ return false; }



Iterator Iterator::operator ++() //syntax wrong..
{

return;

}

Iterator& Container::NewIterator() const
{

return *new Container (*this); 


}

I am also not sure if i did the virtual Iterator& NewIterator () const; right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:55:43+00:00Added an answer on May 17, 2026 at 9:55 pm

    I think you should have a look at the iterators in the STL. It will help you for your conception.

    About your code, operator++ is declared to return void, which is wrong. You also forgot the other version of operator++, the operator– and operator-> member functions which are great helpers to use iterators.

    Your container has no member variable to actually store data and NewIterator has an infinite recursion in it.

    You also lack a lot of references.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This isn't a holy war, this isn't a question of which is better. What
This isn't a question but I thought I'd start a thread where links to
I know this isn't strictly a programming question but y'all must have experienced this.
I know this isn't strictly speaking a programming question but something I always hear
This isn't legal: public class MyBaseClass { public MyBaseClass() {} public MyBaseClass(object arg) {}
This isn't as malicious as it sounds, I want to get the current size
This isn't my code; I am trying to figure out what exactly this does.
This isn't working. Can this be done in find? Or do I need to
this isn't asp.net specific, some of these apps are WinForms, also will be adding
This isn't quite as straight forward as one may think. I'm using a plugin

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.