Есть класс Односвязный список
Код:
#include "ListInterface.h"
#include "Node.h"
//#include "PrecondViolatedExcep.h"
template < class ItemType>
class LinkedList : public ListInterface <ItemType>
{
private:
Node < ItemType >* headPtr; // Pointer to first node in the chain
// (contains the first entry in the list)
Node <ItemType> * CurPtr;
int itemCount; // Current count of list items
// Locates a specified node in a linked list.
// @pre position is the number of the desired node;
// position >= 1 and position <= itemCount.
// @post The node is found and a pointer to it is returned.
// @param position The number of the node to locate.
// @return A pointer to the node at the given position.
Node<ItemType>* getNodeAt(int position) const;
public:
LinkedList();
LinkedList(const LinkedList<ItemType>& aList);
virtual ~LinkedList();
bool isEmpty() const;
int getLength() const;
bool insert(int newPosition, const ItemType& newEntry);
bool remove(int position);
void clear();
ItemType peek(int position) const;
/** @throw PrecondViolatedExcep if position < 1 or
position > getLength(). */
ItemType getEntry(int position) const; //throw(PrecondViolatedExcep);
/** @throw PrecondViolatedExcep if position < 1 or
position > getLength(). */
void setEntry(int position, const ItemType& newEntry);
//throw (PrecondViolatedExcep);
}; // end LinkedList
описание методов класса, опишу только один, для тестирования
Код:
#include"LinkedList.h"
template<class ItemType>
void LinkedList<ItemType>::clear()
{
cout << "test";
} // end clear
далее идет класс Циклический односвязный список
Код:
template < class ItemType>
class CircularListHasA : public CircularListInterface<ItemType>
{
private:
ListInterface<ItemType> *listPtr;
//Node < ItemType >* headPtr;
//int itemCount;
public:
//CircularListHasA();
//CircularListHasA(const CircularListHasA<ItemType>& sList);
//virtual ~CircularListHasA();
bool insert(int place, const ItemType& value);
bool remove(const ItemType& anEntry);
//ItemType retrieval(int position) const;
ItemType getEntry(const ItemType & anEntry);
//virtual ItemType setEntry(const ItemType & anEntry);
void clear();
int getLength();
};
описание методов, опишу опять таки только один
Код:
#include "LinkedList.cpp"
#include "CircularListHasA.h"
template <class ItemType >
void CircularListHasA<ItemType>::clear()
{
listPtr->clear();
}
ну и мейн
Код:
#include "CircularListHasA.cpp"
using namespace std;
int main()
{
CircularListHasA <int> list;
LinkedList <int> a;
list.clear();
getchar();
return 0;
}
вопрос, почему при запуске возникает ошибка Необработанное исключение по адресу 0x008A651C в pr1.exe: 0xC0000005: нарушение прав доступа при чтении по адресу 0x00000000.