我创建链接列表,它没有问题,并运行。另外我必须包括二叉树。和它给我这个错误LNK2019无法解析的外部符号。创建二叉树
1> Generating Code... 1> Skipping... (no relevant changes detected) 1> main.cpp 1>main.obj : error LNK2019: unresolved external symbol "public: int __thiscall SDI::BinaryTree::insert(int)" ([email protected]@[email protected]@[email protected]) referenced in function _main 1>main.obj : error LNK2019: unresolved external symbol "public: int __thiscall SDI::BinaryTree::preOrder(void)" ([email protected]@[email protected]@QAEHXZ) referenced in function _main 1>C:\Users\Muugii\Documents\Visual Studio 2013\LinkedList\Debug\LinkedList.exe : fatal error LNK1120: 2 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
BinaryTree.h
IFNDEF SDI_BINARYTREE
定义SDI_BINARYTREE
包括
namespace SDI
{
class BinaryTree
{
class BTNode
{
public:
int data;
BTNode *left;
BTNode *right;
};
public:
BinaryTree();
~BinaryTree();
int insert(const int value);
int preOrder() const;
int clearTree();
private:
BTNode *headPtr;
int insert(const int value, BTNode *leaf);
int clearTree(BTNode *leaf) const;
int preOrder(BTNode *leaf) const;
};
};
#endif
BinaryTree.cpp
Main.cpp的
#include <string>
#include <iostream>
#include "Linkedlist.h"
#include "BinaryTree.h"
using namespace std;
int main(int argc, const char *argv[])
{
SDI::LinkedList myList;
//SDI::BinaryTree myTree;
int inp;
....
if (inp2 == 'a')
{
int num;
cout << "\nPlease enter a value to add: ";
cin >> num;
myTree.insert(num);
cout << "\n\t\tValue has been successfully saved\n\n\n";
}
我试图寻找在线,找不到任何。这将是很大的帮助。
是什么阻止您在发布之前修改格式? –
好吧,它告诉你在那里,“公共:int __thiscall SDI :: BinaryTree :: preOrder(void)”。您没有该方法的实现。 – OldProgrammer