gpt4 book ai didi

c++ - 为什么我得到 "end of file found before the left brace ' {' in hashtable.h(8)"?

转载 作者:行者123 更新时间:2023-11-28 00:16:51 24 4
gpt4 key购买 nike

当我尝试编译时出现错误,我不知道为什么,因为两组大括号都匹配。

   #include <iostream>
#include <vector>
#include <list>
#include <string>
#include <utility>
#include <fstream>

namespace cop4530 {

template <typename T>
class HashTable {
public:
HashTable(size_t size = 101);
~HashTable();
bool contains(const T &);
bool insert(const T &);
bool insert(T && );
bool remove(const T& );
void clear();
bool load(const char *);
void dump();
bool write_to_file(const char *);

// used when improper size is given (for example
// size is 0 or negative)
static const unsigned int default_capacity = 11;
static const unsigned int max_prime = 1301081;

private:
std::vector<std::list<T>> listTab;
void makeEmpty();
void rehash();
size_t myhash(const T &);
unsigned long prime_below(unsigned long);
void setPrimes(std::vector<unsigned long> &);
int currentSize;
}; // end of HashTable

#include "hashtable.hpp"

}; // end of namespace 4530

或者问题可能在 .hpp 甚至 main.cpp 中?

谢谢!

最佳答案

这里:

vector<std::list<T>>

>>> 是大多数编译器将其读取为运算符的标记,例如这一行中的标记:

std::cin >> toto;

这会让你的编译器从这一行变得疯狂,并在之后打印出奇怪的错误。

插入一个空格将其定义为双模板括号标记:

vector<std::list<T> >

关于c++ - 为什么我得到 "end of file found before the left brace ' {' in hashtable.h(8)"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29676235/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com