错误:"Function"未在此范围内声明
Error: "Function" not declared in this scope
我认为这个错误告诉我我的插入功能没有声明,但是据我所知,我的插入功能正确地声明了,并且它在我的班级的公共部分,所以我认为我应该能够在我的主要功能中使用它。我试图将其称为insert(12);
,但是它给我错误:在此范围中没有声明"插入"。
class BST
{
public:
BST();
BST(int* arr, int size);
void insert(int val);
void inOrderTraversal();
void inOrderTraversal(node * Root);
private:
node * Root;
};
void BST::insert(int val)
{
node* temp = new node();
temp->value = val;
if(Root == NULL) {
Root = temp;
return;
}
node* current;
current = Root;
node* parent;
parent = Root;
current = (temp->value < current->value) ? (current->Left) : (current->Right);
while(current != NULL)
{
parent = current;
current = (temp->value < current->value) ? (current->Left) : (current->Right);
}
if(temp->value < parent->value) {
parent->Left = temp;
}
if(temp->value > parent->value) {
parent->Right = temp;
}
}
如果您只是简单地编写insert(12);
,则可能需要创建BST类的实例并作为成员函数访问:
BST tree;
tree.insert(12);
相关文章:
- 错误:未在此范围内声明'reverse'
- 错误:"imread"未在此范围内声明
- 未在此范围内声明错误 'xy'
- Socklen_t未在此范围内声明
- 错误:'[' 之前预期的非限定 id 和错误:'users'未在此范围内声明
- "Main"已在当前范围内声明
- c++ 变量在宏的扩展中没有在这个范围内声明
- C++ 在编译过程中 strtok 函数 Eclipse 说没有在范围内声明?
- 'num1'未在此范围内声明
- 如何找到在本地范围内声明的变量的地址?
- NT状态未在此范围内声明
- 变量未在此范围内声明 数组线性搜索
- 包含文件中的 Typdef "未在此范围内声明"
- 'ClassName'和'ClassInstance'未在此范围内声明
- C++ 中的类之间的数据重新循环 - 错误:'<class name>'未在此范围内声明
- 代码作为 C 文件工作,但不作为C++文件,错误:'__builtin_types_compatible_p'未在此范围内声明
- 如何修复错误:"vreinterpretq_u32_f64"未在此范围内声明 - 在Android上使用Eigen构建
- 如何修复C++中的"arrStud未在此范围内声明"错误
- 错误:"SHGetKnownFolderPath"未在此范围内声明
- 错误:'Sprite'未在此范围内声明