C++ 错误LNK2019:关于什么的未解析外部符号帮助';她失踪了? 1>----构建已启动:项目:项目4,配置:调试Win32------ 1> proj4_driver.cpp 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:class cop4530::BST const&u thiscall cop4530::BST::operator=(class cop4530::BST const&)”(?4$BST@V?$basic_string@DU?$char_traits@D@性病病毒$allocator@D@2@@std@@@cop4530@@QAEABV01@ABV01@@Z) 在函数_main中引用 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:u thiscall cop4530::BST::BST(int)”(?0$BST@V?$basic_string@DU?$char_traits@D@性病病毒$allocator@D@2@@std@@@cop4530@@QAE@H@Z) 在函数_main中引用 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:u thiscall cop4530::BST::BST(类cop4530::BST const&)”(?0$BST@V?$basic_string@DU?$char_traits@D@性病病毒$allocator@D@2@@std@@@cop4530@@QAE@ABV01@@Z) 在函数_main中引用 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:u thiscall cop4530::BST::BST(类std::basic_string,int)”(?0$BST@V?$basic_string@DU?$char_traits@D@性病病毒$allocator@D@2@@std@@@cop4530@@QAE@V?$basic_string@DU?$char_traits@D@性病病毒$allocator@D@2@@std@@H@Z)在函数_main中引用 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:class cop4530::BST const&u thiscall cop4530::BST::operator=(class cop4530::BST const&)”(?4$BST@H@cop4530@@QAEABV01@ABV01@@Z) 在函数_main中引用 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:u thiscall cop4530::BST::BST(int)”(?0$BST@H@cop4530@@QAE@H@Z) 在函数_main中引用 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:u thiscall cop4530::BST::BST(类cop4530::BST const&)”(?0$BST@H@cop4530@@QAE@ABV01@@Z) 在函数_main中引用 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:u thiscall cop4530::BST::BST(类std::basic_string,int)”(?0$BST@H@cop4530@@QAE@V?$basic_string@DU?$char_traits@D@性病病毒$allocator@D@2@@std@@H@Z)在函数_main中引用 1> c:\users\ah09e\documents\visual studio 2010\Projects\project4\Debug\project4.exe:致命错误LNK1120:8个未解析的外部 ======生成:0成功,1失败,0最新,0跳过==========

C++ 错误LNK2019:关于什么的未解析外部符号帮助';她失踪了? 1>----构建已启动:项目:项目4,配置:调试Win32------ 1> proj4_driver.cpp 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:class cop4530::BST const&u thiscall cop4530::BST::operator=(class cop4530::BST const&)”(?4$BST@V?$basic_string@DU?$char_traits@D@性病病毒$allocator@D@2@@std@@@cop4530@@QAEABV01@ABV01@@Z) 在函数_main中引用 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:u thiscall cop4530::BST::BST(int)”(?0$BST@V?$basic_string@DU?$char_traits@D@性病病毒$allocator@D@2@@std@@@cop4530@@QAE@H@Z) 在函数_main中引用 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:u thiscall cop4530::BST::BST(类cop4530::BST const&)”(?0$BST@V?$basic_string@DU?$char_traits@D@性病病毒$allocator@D@2@@std@@@cop4530@@QAE@ABV01@@Z) 在函数_main中引用 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:u thiscall cop4530::BST::BST(类std::basic_string,int)”(?0$BST@V?$basic_string@DU?$char_traits@D@性病病毒$allocator@D@2@@std@@@cop4530@@QAE@V?$basic_string@DU?$char_traits@D@性病病毒$allocator@D@2@@std@@H@Z)在函数_main中引用 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:class cop4530::BST const&u thiscall cop4530::BST::operator=(class cop4530::BST const&)”(?4$BST@H@cop4530@@QAEABV01@ABV01@@Z) 在函数_main中引用 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:u thiscall cop4530::BST::BST(int)”(?0$BST@H@cop4530@@QAE@H@Z) 在函数_main中引用 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:u thiscall cop4530::BST::BST(类cop4530::BST const&)”(?0$BST@H@cop4530@@QAE@ABV01@@Z) 在函数_main中引用 1> proj4_driver.obj:错误LNK2019:未解析的外部符号“public:u thiscall cop4530::BST::BST(类std::basic_string,int)”(?0$BST@H@cop4530@@QAE@V?$basic_string@DU?$char_traits@D@性病病毒$allocator@D@2@@std@@H@Z)在函数_main中引用 1> c:\users\ah09e\documents\visual studio 2010\Projects\project4\Debug\project4.exe:致命错误LNK1120:8个未解析的外部 ======生成:0成功,1失败,0最新,0跳过==========,c++,linker,tree,lnk2019,C++,Linker,Tree,Lnk2019,这是一个司机: 1>------ Build started: Project: project4, Configuration: Debug Win32 ------ 1> proj4_driver.cpp 1>proj4_driver.obj : error LNK2019: unresolved external symbol "public: class cop4530::BST<class std::basic_string<char,struct st

这是一个司机:

1>------ Build started: Project: project4, Configuration: Debug Win32 ------
1>  proj4_driver.cpp
1>proj4_driver.obj : error LNK2019: unresolved external symbol "public: class cop4530::BST<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > const & __thiscall cop4530::BST<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::operator=(class cop4530::BST<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > const &)" (??4?$BST@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@cop4530@@QAEABV01@ABV01@@Z) referenced in function _main
1>proj4_driver.obj : error LNK2019: unresolved external symbol "public: __thiscall cop4530::BST<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::BST<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(int)" (??0?$BST@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@cop4530@@QAE@H@Z) referenced in function _main
1>proj4_driver.obj : error LNK2019: unresolved external symbol "public: __thiscall cop4530::BST<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::BST<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class cop4530::BST<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > const &)" (??0?$BST@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@cop4530@@QAE@ABV01@@Z) referenced in function _main
1>proj4_driver.obj : error LNK2019: unresolved external symbol "public: __thiscall cop4530::BST<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::BST<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (??0?$BST@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@cop4530@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function _main
1>proj4_driver.obj : error LNK2019: unresolved external symbol "public: class cop4530::BST<int> const & __thiscall cop4530::BST<int>::operator=(class cop4530::BST<int> const &)" (??4?$BST@H@cop4530@@QAEABV01@ABV01@@Z) referenced in function _main
1>proj4_driver.obj : error LNK2019: unresolved external symbol "public: __thiscall cop4530::BST<int>::BST<int>(int)" (??0?$BST@H@cop4530@@QAE@H@Z) referenced in function _main
1>proj4_driver.obj : error LNK2019: unresolved external symbol "public: __thiscall cop4530::BST<int>::BST<int>(class cop4530::BST<int> const &)" (??0?$BST@H@cop4530@@QAE@ABV01@@Z) referenced in function _main
1>proj4_driver.obj : error LNK2019: unresolved external symbol "public: __thiscall cop4530::BST<int>::BST<int>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (??0?$BST@H@cop4530@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function _main
1>c:\users\ah09e\documents\visual studio 2010\Projects\project4\Debug\project4.exe : fatal error LNK1120: 8 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
#包括
#包括
#包括“bst.h”
使用名称空间std;
使用名称空间cop4530;
int main(){
字符串输入;
//获取整数值列表

不能将模板的接口和实现分离。请在
.h
-文件中定义方法,否则编译器无法创建具体类型。

如果确实要将模板实现和增量分离。应将
bst.h
中的行尾更改为

template <typename T>
void BST<T>::buildFromInputString(const string input)
{
    //////////makeEmpty();
    cin >> input;

}

template <typename T>
BST<T>::~BST()
{
    makeEmpty();
}

/*template <typename T>
const BST<T>::BST & operator=(const BST & rhs)
{
    if (this != &rhs)
    {
        makeEmpty();
        root = clone( rhs.root)
    }
    return *this;
}*/

template <typename T>
bool BST<T>::empty()
{
//if (contains(root)==(-1)) 
if ( 1==1)  
    return true;
else
    return false;
}

template <typename T>
void BST<T>::printInOrder() const
{
    printInOrder(root);
}

/*template <typename T>
void BST<T>::printLevelOrder() const
{
    printLevelOrder(root);
}*/

template <typename T>
int BST<T>::numOfNodes() const
{
    return numOfNodes(root);
}
template <typename T>
int BST<T>::height() const
{
    return height(root);
}

template <typename T>
void BST<T>::makeEmpty()
{
    makeEmpty(root);
}

template <typename T>
void BST<T>::insert(const T& v)
{
    insert(v, root);
}

template <typename T>
void BST<T>::remove(const T& v)
{
    remove(v, root);
}

template <typename T>
bool BST<T>::contains(const T& v)
{
    return contains(v, root);
}

template <typename T>
bool BST<T>::contains(const T& v, BSTNode *&t)
{
    if( t == NULL)
        return false;
    else if(v < t->element)
        return contains(v, t->left);
    else if(t->element < v)
        return contains(v, t->right);
    else
        return true;
}

template <typename T>
int BST<T>::numOfNodes(BSTNode *t) const
{
    int nodes = 0;
    if (t!=NULL)
    {
        nodes++;
        numOfNodes(t->left);
        numOfNodes(t->right);
    }
    return nodes;
}

template <typename T>
void BST<T>::printInOrder(BSTNode *t) const
{

if (left != 0)
printInOrder(t->left);
cout << t << endl;
if (right != 0)
printInOrder(t->right);

}


//void BST<T>::printLevelOrder(BSTNode *t) const


template <typename T>
void BST<T>::makeEmpty(BSTNode * & t)
{
    if(t != NULL)
    {
        makeEmpty(t->left);
        makeEmpty(t->right);
        delete t;
    }
    t = NULL;
}

template <typename T>
void BST<T>::insert(const T& v, BSTNode *&t)
{
    if(t = NULL)
        t = new BSTNode(v, NULL, NULL);
    else if(v < t->element)
        insert(v,t->left);
    else if(t->element < v)
        insert(v,t->right);
    else
        ;
}

template <typename T>
void BST<T>::remove(const T& v, BSTNode *&t)
{
    if(t == NULL)
        return;
    if(v < t->element)
        remove(v, t->left);
    else if (t->element < v)
        remove(v,t->right);
    else
    {
        BSTNode *oldNode = t;
        t = (t->left != NULL) ? t->left : t->right;
        delete oldNode;
    }

}
//else if (t->left != NULL && t->right != NULL)



template <typename T>
int BST<T>::height(BSTNode *t) const
{
    return t == NULL ? -1: t->height;
}

template <class T>
typename BST<T>::BSTNode * BST<T>::clone(BSTNode *t) const
{
    if(t==NULL)
        return NULL;

    return new BSTNode( t->element, clone(t->left), clone(t->right));

}

bst1.hpp
应该重命名为
bst1.cpp
(您的
bst1.hpp
确实包含您需要的所有实现),因此,编译器可以通过了解
bst1.cpp
中的定义来实例化模板

#include "bst1.cpp"
对一个司机来说没有任何意义,同样地,对一个司机来说也没有任何意义

对于驱动程序编程,您需要从小处着手,逐步推进

从小事做起,首先要调试(并用程序读取调试消息)

您可以找到入门教程


要了解更多信息,我建议您查看Microsoft的驱动程序sdk,这非常有帮助。

您声明了几个BST类构造函数。但实际上您没有为它们编写代码。您根本没有完成。Passant:很可能是这里的问题。谢谢!请注意,如果需要,您可以将接口和实现分离到源文件和头文件中您使用。我以前多次这样做过,更不用说类内要求将接口和实现分为两个不同的文件。请放心,这两个文件都是头文件。只有在编译器支持这一点时。。。
template <typename T>
void BST<T>::buildFromInputString(const string input)
{
    //////////makeEmpty();
    cin >> input;

}

template <typename T>
BST<T>::~BST()
{
    makeEmpty();
}

/*template <typename T>
const BST<T>::BST & operator=(const BST & rhs)
{
    if (this != &rhs)
    {
        makeEmpty();
        root = clone( rhs.root)
    }
    return *this;
}*/

template <typename T>
bool BST<T>::empty()
{
//if (contains(root)==(-1)) 
if ( 1==1)  
    return true;
else
    return false;
}

template <typename T>
void BST<T>::printInOrder() const
{
    printInOrder(root);
}

/*template <typename T>
void BST<T>::printLevelOrder() const
{
    printLevelOrder(root);
}*/

template <typename T>
int BST<T>::numOfNodes() const
{
    return numOfNodes(root);
}
template <typename T>
int BST<T>::height() const
{
    return height(root);
}

template <typename T>
void BST<T>::makeEmpty()
{
    makeEmpty(root);
}

template <typename T>
void BST<T>::insert(const T& v)
{
    insert(v, root);
}

template <typename T>
void BST<T>::remove(const T& v)
{
    remove(v, root);
}

template <typename T>
bool BST<T>::contains(const T& v)
{
    return contains(v, root);
}

template <typename T>
bool BST<T>::contains(const T& v, BSTNode *&t)
{
    if( t == NULL)
        return false;
    else if(v < t->element)
        return contains(v, t->left);
    else if(t->element < v)
        return contains(v, t->right);
    else
        return true;
}

template <typename T>
int BST<T>::numOfNodes(BSTNode *t) const
{
    int nodes = 0;
    if (t!=NULL)
    {
        nodes++;
        numOfNodes(t->left);
        numOfNodes(t->right);
    }
    return nodes;
}

template <typename T>
void BST<T>::printInOrder(BSTNode *t) const
{

if (left != 0)
printInOrder(t->left);
cout << t << endl;
if (right != 0)
printInOrder(t->right);

}


//void BST<T>::printLevelOrder(BSTNode *t) const


template <typename T>
void BST<T>::makeEmpty(BSTNode * & t)
{
    if(t != NULL)
    {
        makeEmpty(t->left);
        makeEmpty(t->right);
        delete t;
    }
    t = NULL;
}

template <typename T>
void BST<T>::insert(const T& v, BSTNode *&t)
{
    if(t = NULL)
        t = new BSTNode(v, NULL, NULL);
    else if(v < t->element)
        insert(v,t->left);
    else if(t->element < v)
        insert(v,t->right);
    else
        ;
}

template <typename T>
void BST<T>::remove(const T& v, BSTNode *&t)
{
    if(t == NULL)
        return;
    if(v < t->element)
        remove(v, t->left);
    else if (t->element < v)
        remove(v,t->right);
    else
    {
        BSTNode *oldNode = t;
        t = (t->left != NULL) ? t->left : t->right;
        delete oldNode;
    }

}
//else if (t->left != NULL && t->right != NULL)



template <typename T>
int BST<T>::height(BSTNode *t) const
{
    return t == NULL ? -1: t->height;
}

template <class T>
typename BST<T>::BSTNode * BST<T>::clone(BSTNode *t) const
{
    if(t==NULL)
        return NULL;

    return new BSTNode( t->element, clone(t->left), clone(t->right));

}
#include "bst1.hpp"
#include "bst1.cpp"
getline(cin, input);