源文件编译器错误 - 常见问题
sourceFile compiler errors - common issue
我
从sourceForge获得的这个sourceFile中有26个错误。它是斯坦福CS106B库的一部分,因此应该没有任何错误。
错误示例:
- C2059:语法错误:"公共"C2990:"迭代器":非类模板已声明为类模板
- C2255: "friend":不允许超出类定义
- C2146:语法错误:标识符"foreachHook"之前缺少";"
- C4430:缺少类型说明符 - 假定为 int。注意:C++不支持默认整数
- C2065:"FE_State":未声明的标识符
有了这么多错误,直觉是可能有一个简单的原因,而不是26个复杂的原因。
/*
* File: private/bst.h
* Last modified on Fri Jun 5 15:40:43 2009 by eroberts
* -----------------------------------------------------
* This file contains the private section of the bst.h interface.
* This portion of the class definition is taken out of the bst.h
* header so that the client need not have to see all of these
* details.
*/
public:
/*
* Class: BST<ElemType>::Iterator
* ------------------------------
* This interface defines a nested class within the BST template that
* provides iterator access to the keys contained in the BST.
*/
class Iterator {
public:
Iterator();
bool hasNext();
ElemType next();
private:
struct iteratorMarkerT {
void *np;
bool processed;
};
Iterator(BST *bstp);
BST *bstp;
Stack<iteratorMarkerT> stack;
long timestamp;
void advanceToNextNode();
void findLeftmostChild();
friend class BST;
};
friend class Iterator;
ElemType foreachHook(FE_State & _fe);
/*
* Deep copying support
* --------------------
* This copy constructor and operator= are defined to make a
* deep copy, making it possible to pass/return trees by value
* and assign from one tree to another. The entire contents of
* the tree, including all elements, are copied. Each tree
* element is copied from the original tree to the copy using
* assignment (operator=). Making copies is generally avoided
* because of the expense and thus, trees are typically passed
* by reference, however, when a copy is needed, these operations
* are supported.
*/
const BST & operator=(const BST & rhs);
BST(const BST & rhs);
private:
/* Type definition for node in the tree */
struct nodeT {
ElemType data;
nodeT *left, *right;
int bf; /* AVL balance factor */
};
/* Constant definitions */
static const int BST_RIGHT_HEAVY = +1;
static const int BST_IN_BALANCE = 0;
static const int BST_LEFT_HEAVY = -1;
/* Instance variables */
nodeT *root;
int numNodes;
long timestamp;
int (*cmpFn)(ElemType, ElemType);
/* Private method prototypes */
nodeT *recFindNode(nodeT *t, ElemType & key);
bool recAddNode(nodeT * & t, ElemType & key, bool & createdNewNode);
bool recRemoveNode(nodeT * & t, ElemType & key, bool & didRemove);
bool removeTargetNode(nodeT * & t);
void updateBF(nodeT * & t, int bfDelta);
void recDeleteTree(nodeT *t);
void recBSTAll(nodeT *t, void (*fn)(ElemType));
void fixRightImbalance(nodeT * & t);
void fixLeftImbalance(nodeT * & t);
void rotateRight(nodeT * & t);
void rotateLeft(nodeT * & t);
void copyOtherEntries(const BST & other);
/* Template method prototypes */
template <typename ClientDataType>
void recBSTAll(nodeT *t, void (*fn)(ElemType, ClientDataType &),
ClientDataType & data);
此文件本身不构成有效的C++。如果您阅读了注释,则会将其从bst.h
中取出以形成类的私有部分,而无需客户端(库的用户)查看详细信息。 只有当它在正确的位置#include
bst.h
时,private/bst.h
才有意义。然后,编译器将在正确的上下文中解析它。
查看此文件上方目录中的文件bst.h
( private/bst.h
)。
相关文章:
- 谷歌启动B轮巴士路线问题错误的答案?
- C++编译问题错误 - C2332:<类:缺少标记名称>
- 编译方面的问题.错误E0413、E0434、C2664、C2440
- 在C 中的初学者,我面临此问题错误C3867
- C++:创建线程时出现问题;错误 C2672:"std::invoke":找不到匹配的重载函数
- 模板方法定义的问题 - 错误C2244:无法将函数定义与现有声明匹配
- C 继承问题错误C2084功能已经具有主体
- 安装 QT 后的新手问题 - 错误:未知类型名称"QApplication"
- Stroustrup的代码审查-编程原理-Ch-4-问题:3-错误:矢量下标超出范围
- C 问题错误在此函数中被统一使用
- 常见问题TDD与模拟
- 如何理解C++常见问题中的"程序忽略我的输入请求"?
- 内联与#define的C++常见问题解答示例
- C++常见问题 32.8 "pass an object of a C++ class to/from a C function"问题
- 源文件编译器错误 - 常见问题
- 返回模板类的模板函数 - GCC 编译问题 - 错误:令牌之前'<'预期非限定 ID
- CMake CLion 问题 - 错误:无法确定目标"XYZ"的链接语言
- C++常见问题解答的不安全宏的解释?
- 试图将数据写入文件时出现问题.错误LNK2019:未解析的外部符号
- c++初始化列表问题-错误:试图引用已删除的函数