我收到这些错误
C:\ Users \ SDRav \ AppData \ Local \ Temp \ ccCy0RiX.o:driver.cpp :(。text + 0x1b):对BST<char>::BST()'
C:\Users\SDRav\AppData\Local\Temp\ccCy0RiX.o:driver.cpp:(.text+0x1eb): undefined reference to
BST :: insert(char const&)的未定义引用C:\ Users \ SDRav \ AppData \ Local \ Temp \ ccCy0RiX.o:driver.cpp :(。text + 0x228):对BST<char>::traversePreorder(BSTNode<char>*)'
C:\Users\SDRav\AppData\Local\Temp\ccCy0RiX.o:driver.cpp:(.text+0x263): undefined reference to
BST :: search(char const&)const的未定义引用C:\ Users \ SDRav \ AppData \ Local \ Temp \ ccCy0RiX.o:driver.cpp :(。text + 0x32b):对BST<char>::deleteNode(char const&)'
C:\Users\SDRav\AppData\Local\Temp\ccCy0RiX.o:driver.cpp:(.text+0x419): undefined reference to
BST :: leafCount(BSTNode *)的未定义引用C:\ Users \ SDRav \ AppData \ Local \ Temp \ ccCy0RiX.o:driver.cpp :(。text + 0x47c):对BST<char>::search(char const&) const'
C:\Users\SDRav\AppData\Local\Temp\ccCy0RiX.o:driver.cpp:(.text+0x4d5): undefined reference to
BST :: getSiblings(char const&)的未定义引用collect2.exe:错误:ld返回1退出状态
但是我不知道为什么。...我的猜测正在链接,但是我已经检查了标头,但我仍然看不到它
我的代码
#include <iostream> #include <iomanip> #include "BST.h" using namespace std; int main() { BST<char> op1; int action = 0; int numInsert = 0; char value; cout<<"-------------------- MENU ----------------------" <<endl<<"1. Insert node(s)" <<endl<<"2. Traverse Preorder" <<endl<<"3. Search BST" <<endl<<"4. Delete node" <<endl<<"5. Leaf Count" <<endl<<"6. Sibling of a node" <<endl<<"7. Quit" <<endl<<"Please ent switch (action) { case 1: cout << "\n How many values would you liek to insert to a BST? "; cin>>numInsert; for(int i =0; i<numInsert;i++){ cout<<"What value would you like to insert to the list: "; cin >> value; op1.insert(value); //check } break; ... }
请帮助
我收到这些错误C:\ Users \ SDRav \ AppData \ Local \ Temp \ ccCy0RiX.o:driver.cpp :(。text + 0x1b):对BST的未定义引用<:: bst users sdrav appdata local temp cccy0rix.o : ...>] >> [[#include <iostream>
#include "BSTNode.h"
using namespace std;
#ifndef BINARY
#define BINARY
template <typename DataType>
class BST
{
public:
BST();
// ~BST();
bool empty() const;
/*------------------------------------------------------------------------
Check if BST is empty.
Precondition: None.
Postcondition: Returns true if BST is empty and false otherwise.
-----------------------------------------------------------------------*/
void insert(const DataType & item);
void traversePreorder(BSTNode<DataType> * startPoint);
bool search(const DataType & item)const;
bool deleteNode(const DataType & item);
int leafCount(BSTNode<DataType> * startPoint);
DataType getSiblings(const DataType & item);
private:
BSTNode<DataType> * treeRoot;
typedef BSTNode<DataType> * BSTNodePointer;
void search2(const DataType & item, bool & found, BSTNodePointer & locptr, BSTNodePointer & parent) const;
};