I'm attempting to build a template class Heap
that will take any data type and store it in the class wordList
(called this because it will ultimately take words as parameters). This is being developed in xCode environment. When heap is called in the main the following error is delivered at compile time.
Error: "heap<std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> > >::heap(std::__1::vector<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> >,
std::__1::allocator<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > > >)",
referenced from: _main in main.o"
Is this a problem anyone else has run into and if so how did you resolve it?
Code is presented below:
template <class A_type> class heap
{
public:
heap(vector<A_type> wordlist);
private:
vector<A_type> wordList;
};
template <class A_type>
heap<A_type>::heap(vector<A_type> word)
{
wordList.resize(word.size());
wordList = word;
}
int main()
{
vector<string> words;
string word;
for (int index=0;index<5; index ++)
{
cout << "Enter word";
cin >> word;
words.push_back(word);
}
heap<string> newHeap(words);
return 0;
}
Thanks!