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?