错误C2061:语法错误:标识符'EntryType'

时间:2015-08-08 12:40:55

标签: c++ constructor enums

我收到了这个错误,我不知道为什么。我从Mark Allen Weiss的书中得到了部分代码。他使hashEntry结构完全相同(虽然我使用了不同的名称)。我使用enum或忘记包含某些内容时做错了吗?

#ifndef QHASHTABLE
#define QHASHTABLE

#include <iostream>
#include <vector>

#include "functions.h"

using namespace std;

class quadraticHashTable
{
public:
    explicit quadraticHashTable(int size = 101)
    : hashArray(nextPrime(size)), currentSize{0}
    { makeEmpty(); };           

    bool contains(const int & searchItem);
    void makeEmpty();
    bool insert(const int & insertItem);
    bool remove(const int & removeItem);
    int getCurrentSize();
    void testDisplay() const;

    enum EntryType { ACTIVE, EMPTY, DELETED }; //ACTIVE = 0, EMPTY = 1, DELETED = 2

private:
    struct hashEntry
    {
        int value;
        EntryType status;

        hashEntry(const int & v = int{}, EntryType s = EMPTY)  //ERROR HERE
        : value( v ), status( s ){}
    };

    size_t hashFunction(int value);
    bool isActive(int currentPos) const;
    int findPos(const int & value);
    void reHash();
    void reHashDelete();

    vector<hashEntry> hashArray;
    int currentSize;
};

0 个答案:

没有答案