类不命名数据类型?



我不知道我做了什么,因为它工作正常(即有不同的错误(,然后突然间我的整个类都不存在了,因为现在我所有的函数声明和定义都没有发生。我不知道怎么了。

我找不到包含,语法,标题,标题保护,拼写的任何问题。我真的什么也找不到。我希望这是愚蠢的事情,但我不明白它为什么要这样做。有人请帮忙!我已经将 LinkedList 的 cpp 文件的 #include 放在标题上,并像往常一样将标题包含在 cpp 上,并包含在两者中,但它们都没有工作。我对所有单词进行了三重阅读,以确保所有拼写和所有内容都匹配。

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

链接列表.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

错误: LinkedList.cpp:4:错误:"LinkedList"未命名类型 LinkedList::LinkedList((

Lab-04/LinkedList.cpp:10:错误:"<"令牌之前的预期初始值设定项 void LinkedList::addFront(SLNode *entry(

CPP 中的所有函数都具有与第二个函数相同的错误

它对我来说看起来不错,我认为你的 isEmpty(( 函数没有被覆盖,因为它在接口中声明了常量。但这是在派生类中没有 const 的情况下实现的。你也没有提供SLNode类其他问题可以在那里找到

相关内容

  • 没有找到相关文章

最新更新