c++ - 编译错误 c++ "was not declared in this scope" "expected type specifier"等

标签 c++ compiler-errors g++

<分区>

这是我看到的错误列表

RST.hpp:23:18: error: ‘RSTNode’ has not been declared
RST.hpp:23:38: error: ‘RSTNode’ has not been declared
RST.hpp:23:45: error: expected ‘,’ or ‘...’ before ‘<’ token
RST.hpp:41:30: error: ‘RSTNode’ has not been declared
RST.hpp:41:37: error: expected ‘,’ or ‘...’ before ‘<’ token
RST.hpp:44:28: error: ‘RSTNode’ has not been declared
RST.hpp:44:35: error: expected ‘,’ or ‘...’ before ‘<’ token
RST.hpp: In member function ‘virtual void RST<Data>::leftRotate(int)’:
RST.hpp:25:7: error: ‘RSTNode’ was not declared in this scope
RST.hpp:25:19: error: expected primary-expression before ‘>’ token
RST.hpp:25:23: error: ‘dummyone’ was not declared in this scope
RST.hpp:25:34: error: ‘ptr’ was not declared in this scope
RST.hpp:26:19: error: expected primary-expression before ‘>’ token
RST.hpp:26:23: error: ‘dummytwo’ was not declared in this scope
RST.hpp:27:19: error: expected primary-expression before ‘>’ token
RST.hpp:27:23: error: ‘dummythree’ was not declared in this scope
RST.hpp: In member function ‘virtual bool RST<Data>::addToTree(int)’:
RST.hpp:46:11: error: ‘ptr’ was not declared in this scope
RST.hpp:48:13: error: ‘num’ was not declared in this scope
RST.hpp:50:11: error: ‘temp’ was not declared in this scope
RST.hpp:55:11: error: ‘temp’ was not declared in this scope
RST.hpp:63:20: error: expected type-specifier before ‘RSTNode’
RST.hpp:63:20: error: expected ‘;’ before ‘RSTNode’
RST.hpp:64:23: error: ‘temp’ was not declared in this scope
RST.hpp: In member function ‘bool RST<Data>::insert(const Data&) [with Data = countint]’:
test_RST.cpp:43:23:   instantiated from here
RST.hpp:14:7: error: no matching function for call to             RST<countint>::addToTree(BSTNode<countint>*&, NULL, const countint&)’
RST.hpp:14:7: note: candidate is:
RST.hpp:44:18: note: bool RST<Data>::addToTree(int) [with Data = countint]
RST.hpp:44:18: note:   candidate expects 1 argument, 3 provided

这是我的所有代码,除了测试器,这在这点上很好 http://pastebin.com/3zu0hAy1

请帮忙,我不确定为什么会这样!

注意:BST 是 RST 的父类(super class)//BSTNode 是 RSTNode 的父类(super class)

谢谢

最佳答案

问题似乎是您没有在“RST.hpp”中包含“RSTNode.hpp”。所以“RSTNode not declared”错误消息是完全正确的。

这个错误不是我在你之前的问题中猜到的,所以你最好撤消那个更改。

关于c++ - 编译错误 c++ "was not declared in this scope" "expected type specifier"等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13082239/

相关文章:

c++ - 通过函数返回枚举

C++:没有断点工作

c - Flex 中 '(' 标记之前的预期标识符或 '{'

c++ - Eclipse 编译调试与 native 调试(C++ 代码)

xcode - 处理 Swift 编译器的误导性错误消息(上下文依赖、类型推断)

c++ - 为什么我的可执行文件的 .dynstr 包含静态链接库中的符号?

c++ - 构造函数应该如何报告错误?指向外部标志的指针?

c++ - 如果尝试将负数分配给未签名的容器,是否有导致编译错误的方法?

c++ - 在 g++ 中使用 std::variant

c++ - Visual C++ 中的浮点精度