c++ - error LNK2019: unresolved external symbol Help on what's missing? -


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 ========== 

this here driver:

    #include <iostream>     #include <string>     #include "bst.h"      using namespace std;     using namespace cop4530;      int main() {     string input;  // list of integer values cout << "enter list of integer values in 1 line: "; getline(cin, input);  // create binary search tree bst<int> bst1(input); if (!bst1.empty()) {     cout << "inorder traversal: ";     bst1.printinorder();     cout << "level order traversal: "; /////////////bst1.printlevelorder();      // test copy constructor     bst<int> bst2(bst1);     cout << "testing copy constructor: ";     //////////////bst2.printlevelorder();      // test assignment operator     bst<int> bst3;     bst3 = bst1;     cout << "testing assignment operator: ";     ////////////bst3.printlevelorder();  }  // list of string values cout << "enter list of string values in 1 line: "; getline(cin, input);  // create binary search tree bst<string> bsts1(input); if (!bsts1.empty()) {     cout << "inorder traversal: ";     bsts1.printinorder();     cout << "level order traversal: "; ////////bsts1.printlevelorder();      // test copy constructor     bst<string> bst2(bsts1);     cout << "testing copy constructor: ";     ////////////bst2.printlevelorder();      // test assignment operator     bst<string> bst3;     bst3 = bsts1;     cout << "testing assignment operator: ";     ///////////bst3.printlevelorder();  }  cout << "enter list of integer values: "; getline(cin, input); /////bst1.buildfrominputstring(input); cout << "level order traversal: "; ////bst1.printlevelorder();  cout << "\n===================\n"; cout << "operation manual:" << endl; cout << "d: delete value;\ti: insert value;" << endl; cout << "h: height of tree; \tn: number of nodes" << endl; cout << "o: in order print; \tl: level order print" << endl; cout << "s: search value;\tq: quit" << endl; cout << "===================\n"; cout << "choice: "; int tmp; while (getline(cin, input)) { if (input == "q")     break; if (input == "d") {     cout << "type value delete: ";     cin >> tmp;     cin.ignore();     bst1.remove(tmp); } else if (input == "i") {     cout << "type value insert: ";     cin >> tmp;     cin.ignore();     bst1.insert(tmp); } else if (input == "o") {     cout << "in order traversal: ";     bst1.printinorder(); } else if (input == "l") {     cout << "level order traversal: ";     ///////bst1.printlevelorder(); } else if (input == "h") {     cout << "height: ";     cout << bst1.height() << endl; } else if (input == "n") {     cout << "number of nodes: ";     cout << bst1.numofnodes() << endl; } else if (input == "s") {     cout << "type value search: ";     cin >> tmp;     cin.ignore();     if (bst1.contains(tmp)) {     cout << "contains " << tmp << endl;     } else {     cout << "does not contains " << tmp << endl;     } }  cout << "\n===================\n"; cout << "operation manual:" << endl; cout << "d: delete value;\ti: insert value;" << endl; cout << "h: height of tree; \tn: number of nodes" << endl; cout << "o: in order print; \tl: level order print" << endl; cout << "s: search value;\tq: quit" << endl; cout << "===================\n"; cout << "choice: "; } return 0; } 

and bst.h:

#ifndef cop4530_proj4_h #define cop4530_proj4_h  #include<iostream> #include<string> using std::string;  namespace cop4530{  //using std::string; int default_threshold_value = 1;  template <typename t> class bst {  public:  bst(int th=default_threshold_value);  bst(const string input, int th=default_threshold_value); bst(const bst&); ~bst();// void buildfrominputstring(const string input); const bst & operator=(const bst & rhs);// bool empty();//   void printinorder() const;// //void printlevelorder() const;// int numofnodes() const;// int height() const;// void makeempty();// void insert(const t& v);// void remove(const t& v);// bool contains (const t& v);//   private: struct bstnode { t element; bstnode *left; bstnode *right; int height; //void printinorder(bstnode *t) const;  bstnode(const t & theelement, bstnode *lt, bstnode *rt, int h=0)     : element(theelement), left(lt), right(rt), height(h) {} };  bstnode *root;  void printinorder(bstnode *t) const;// //void printlevelorder(bstnode *t) const; void makeempty(bstnode* &t);// void insert(const t& v, bstnode *&t);// void remove(const t& v, bstnode *&t);// bool contains(const t& v, bstnode *&t);// int numofnodes(bstnode *t) const;// int height(bstnode *t) const;// bstnode * clone(bstnode *t) const;//  }; #include "bst1.hpp" } #endif 

and here bst1.hpp

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));  } 

i'm having linker problem. couldn't find code on site address problem specifically. been working on binary search tree little results remedying particular aspect. far i'm concerned libraries , files added in respective areas, appreciate help.

you must not separate interface , implementation templates. define methods in .h-file, otherwise compiler can't create concrete types.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -