I have the following .cpp file code - see towards last line of code where the compile error 2664 occurs. Please help. Thanks.
This is the header file which the call references it can't convert Error 1 error C2664: 'bSearchTreeType<elemType>::insert' : cannot convert parameter 1 from 'dictionary' to 'const std::string &'
//Header File Binary Search Tree
#ifndef
H_binarySearchTree#define
H_binarySearchTree#include
<iostream>#include
<cassert>#include
"binaryTree.h"using
namespace std;template
<class elemType>class
bSearchTreeType: public binaryTreeType<elemType>{
public
: bool search(const elemType& searchItem); void insert(const elemType& insertItem);};
This is the .cpp file which calls the above header file.
#include
<iostream>#include
<string>#include
<fstream>#include
"binarySearchTree.h"#include
"binaryTree.h"using
namespace std;class
dictionary{
friend ostream& operator<<(ostream&, const dictionary&); public: void addSet(string name1, string description1); void remove(); void lookup();dictionary(string name =
"",string description = ""); protected:string name;
string description;
};
void
dictionary::addSet(string name1,string description1){
name = name1;
description = description1;
}
void
createDictionary(ifstream& infile,bSearchTreeType<string>& dict);
int
main(){
bSearchTreeType<string> dict;
int choice; char ch;ifstream infile;
infile.open(
"fileextensiondictionary.txt"); if(!infile){
cout<<
"The input file does not exist."<<endl; return 1;}
createDictionary(infile, dict);
infile.close;
return 0;}
void
createDictionary(ifstream& infile,bSearchTreeType<string>& dict)
{
string Name1;
string description1;
dictionary first;
while(infile){
getline(infile,Name1,
' ');getline(infile,description1);
first.addSet(Name1,description1);
dict.insert(first); // THIS LINE GIVES ME A COMPILE ERROR 2664
}
//end while}
//end createDictionary
Compile Error 2664
good metric