我遇到了這個問題,在我的跳過列表實現中出現奇怪的語法錯誤,並且嚴重地不知道會導致這種情況。實現跳過列表,語法錯誤:在'之前'缺少')';'
這是代碼:
skipnode.h:
template <typename T>
class SkipNode
{
public:
T data;
SkipNode<T> **next;
SkipNode(T d, int level);
~SkipNode();
};
skipnode.cpp
#include "skipnode.h"
template<typename T>
SkipNode<T>::SkipNode(T d, int level)
{
data = d;
next = new SkipNode<T>*[level];
for (int i = 0; i <= level; i++)
next[i] = 0;
}
template<typename T>
SkipNode<T>::~SkipNode()
{
delete [] next;
}
Skiplist.h
#include "skipnode.cpp"
#define MAXLEVEL 4;
template<typename T>
class SkipList
{
public:
SkipList();
~SkipList();
int randLvl(int max);
T search(T);
void insert(T);
private:
SkipNode<T> *root;
};
Skiplist.cpp
#include "skiplist.h"
template<typename T>
SkipList<T>::SkipList()
{
root = new SkipNode<T>(0,MAXLEVEL);
}
當我在Skiplist聲明根()我收到以下錯誤:
error C2143: syntax error : missing ')' before ';'
誰能幫助我嗎?提前致謝。
編輯:固定的代碼,所以演出內容包括
編譯器通常顯示行數時,他們報告這種錯誤...... – dandan78 2014-12-03 14:10:43