Reputation: 3
I don't know what I did, because it was working fine (i.e. had different errors) and then suddenly my entire class just didn't exist or something because now all my function declarations and definitions just aren't happening. I don't know what's wrong.
I cannot find any issues with the includes, the syntax, the headers, the header guards, the spelling. I literally can find nothing. I hope it's something stupid, but I don't understand why it's doing this. Someone please help! I have put my #include of the cpp file for the LinkedList on the header and included the header on the cpp like normal and included in both and none of them have worked. i have triple read all the words to make sure all the spelling and everything matches.
LinkedList.h
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
#include "SLNode.h"
#include "ListInterface.h"
template <typename ItemType>
class LinkedList: public ListInterface<ItemType>
{
public:
LinkedList();
void addFront(SLNode<ItemType>* entry);
bool isEmpty();
int getLength () const;
void insert(int newPosition, const ItemType &newEntry);
void remove (int position);
void clear();
ItemType getEntry(int position) const;
void setEntry (int position, const ItemType& newEntry);
private:
SLNode<ItemType>* m_front;
};
#include "LinkedList.cpp"
#endif // LINKEDLIST_H
LinkedList.cpp
#include <iostream>
template <typename ItemType>
LinkedList<ItemType>::LinkedList()
{
m_front = nullptr;
}
template <typename ItemType>
void LinkedList<ItemType>::addFront(SLNode<ItemType> *entry){}
template <typename ItemType>
bool LinkedList<ItemType>::isEmpty (){}
template <typename ItemType>
int LinkedList<ItemType>::getLength() const{}
template <typename ItemType>
void LinkedList<ItemType>::insert(int newPosition, const ItemType &newEntry){}
template <typename ItemType>
void LinkedList<ItemType>::remove(int position){}
template <typename ItemType>
void LinkedList<ItemType>::clear() {}
template <typename ItemType>
ItemType LinkedList<ItemType>::getEntry(int position) const {}
template <typename ItemType>
void LinkedList<ItemType>::setEntry(int position, const ItemType &newEntry){}
ListInterface.h
ListInterface.h
#ifndef _LIST_INTERFACE
#define _LIST_INTERFACE
#include "PrecondViolatedExcep.h"
template<class ItemType>
class ListInterface
{
public:
/** Virtual destructor allows concrete implementations to clean up
heap memory when the List is discarded. */
virtual ~ListInterface() {}
/** Sees whether this list is empty.
@return True if the list is empty; otherwise returns false. */
virtual bool isEmpty() const = 0;
/** Gets the current number of entries in this list.
@return The integer number of entries currently in the list. */
virtual int getLength() const = 0;
/** Inserts an entry into this list at a given position.
@pre None.
@post If 1 <= position <= getLength() + 1 and the insertion is
successful, newEntry is at the given position in the list, and
other entries are renumbered accordingly.
@param newPosition The list position at which to insert newEntry.
@param newEntry The entry to insert into the list.
@throw PrecondViolatedExcep if insertion cannot be performed. */
virtual void insert(int newPosition, const ItemType& newEntry) /*
throw(PrecondViolatedExcep) */ = 0;
/** Removes the entry at a given position from this list.
@pre None.
@post If 1 <= position <= getLength() and the removal is successful,
the entry at the given position in the list is removed, and other
items are renumbered accordingly.
@param position The list position of the entry to remove.
@throw PrecondViolatedExcep if removal cannot be performed. */
virtual void remove(int position) /* throw(PrecondViolatedExcep) */ = 0;
/** Removes all entries from this list.
@post List contains no entries and the count of items is 0. */
virtual void clear() = 0;
/** Gets the entry at the given position in this list.
@pre 1 <= position <= getLength().
@post The desired entry has been returned.
@param position The list position of the desired entry.
@throw PrecondViolatedExcep if no such entry exists. */
virtual ItemType getEntry(int position) const /*
throw(PrecondViolatedExcep) */ = 0;
/** Replaces the entry at the given position in this list.
@pre 1 <= position <= getLength().
@post The entry at the given position is newEntry.
@param position The list position of the entry to replace.
@param newEntry The replacement entry.
@throw PrecondViolatedExcep if no such entry exists. */
virtual void setEntry(int position, const ItemType& newEntry) /*
throw(PrecondViolatedExcep) */ = 0;
}; // end ListInterface
#endif
Errors: LinkedList.cpp:4: error: 'LinkedList' does not name a type LinkedList::LinkedList()
Lab-04/LinkedList.cpp:10: error: expected initializer before '<' token void LinkedList::addFront(SLNode *entry)
all the functions in the cpp have the same error as the second one
Upvotes: 0
Views: 75
Reputation: 337
Its look fine to me, I think your isEmpty() function is not overridden as this declare const in interface. But this is implemented without const in derived class. You also didn’t supply SLNode class other issues can be find there
Upvotes: 0