在针对我的大学教授main.cpp编译我的代码时,我遇到了3个错误
7 0 在main.cpp中包含的文件
3 8 [错误]在'之前预期的构造函数,析构函数或类型转换。' 令牌
28 C:\ Users \ Joe \ Desktop \ school \ Makefile.win 目标' main.o'失败
这是我的ntree.h文件
* Ntree.h - header and implementation file for classes Tnode, Ntree //this line is the one getting the error
* Limitations: values cannot contain '(' and ')' characters.
* Can be changed by redefining TOKEN_BEGIN and TOKEN_END
#ifndef _NTREE_H
#define _NTREE_H
#define TOKEN_BEGIN '('
#define TOKEN_END ')'
#include <iostream>
#include <fstream>
#include <cstddef>
#include <vector>
#include <string>
#include <stack>
#include <sstream>
template <typename T>
class Tnode
{
private:
T value;
std::vector<Tnode*> children;
public:
Tnode (T data = {}); // copy constructor
~Tnode(); // destructor
T getValue() const; // gets the value
size_t getChildrenCount() const;
Tnode* getChild(size_t n) const; // get child by number
void setValue(T data); // sets for value
void addChild(Tnode *node); // add child node
void addChild(T data); // creates a node and adds child with a value
bool operator== ( Tnode<T> & other) const; // overload operator
};
template <typename T>
class Ntree{
private:
Tnode<T>* rootPtr;
int numOfNodes;
// utility function get node with current value
Tnode<T>* getNodeByValue(Tnode<T> *node, T data);
// utility function get value from the stream
std::string getToken(std::ifstream & ifs);
void serialize(std::ofstream & ofs, Tnode<T> *node);
public:
Ntree(); // default constructor
Ntree(T val); // constructor with root initialization
~Ntree(); // destructor
void addChildren(T parent, std::initializer_list<T> ini_list);
void serialize(std::string fname);
void deserialize(std::string fname);
bool operator== (Ntree<T> & other);
};
答案 0 :(得分:1)
尝试评论前3行。你确定你知道前几行是什么意思吗?