我一直在Visual Studio中定义“类”。希望是一个简单的解决方法
代码:
main.ccp:
#include "pch.h"
#include <iostream>
#include <iomanip>
#include "TreeNode.h"
#include "AVLTree.h"
int main()
{
AVLTree first;
int y = 1;
bool x = true;
x = first.insert(1,2);
std::cout << x << std::endl;
std::cout << y << std::endl;
}
AVLTree.h:
#pragma once
class AVLTree
{
int nodeCounter = 0;
TreeNode * rootNode = 0; // It says the error is here (TreeNode undefined)
public:
AVLTree();
~AVLTree();
bool insert(int key, int value);
};
TreeNode.h:
#pragma once
class TreeNode
{
int data;
int key;
TreeNode * nextPtr;
public:
TreeNode();
~TreeNode();
};
答案 0 :(得分:0)
尝试将以下内容添加到AVLTree.h:
class TreeNode;
以下是AVLTree.cpp:
#include "TreeNode.h"