Hey friends,
I am working on a program where I have a given class (Dictionary). I am supposed to make a concrete class (Word) which implements Dictionary. I should mention that I am not to change anything in Dictionary.
After making a header file for Word, I define everything in word.cpp.
I am unsure if I am doing this correctly, but I make the constructor read from a given file, and store the information in a public member of Word.
(I understand that it should be private, but I made it public to get to the root of this current issue)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#ifndef __DICTIONARY_H__
#define __DICTIONARY_H__
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
class Dictionary
{
public:
Dictionary(istream&);
virtual int search(string keyword, size_t prefix_length)=0;
};
#endif /* __DICTIONARY_H__ */
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#ifndef __WORD_H__
#define __WORD_H__
#include "dictionary.h"
class Word : public Dictionary{
public:
vector<string> dictionary_words;
Word(istream &file);
int search(string keyword, size_t prefix_length);
int permutation_search(string keyword,string prefix, ofstream& fout,size_t prefix_length);
};
#endif /* __WORD_H__*/
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include "word.h"
Word::Word(istream& file)
{
while (file.eof() == false)
{
string temp="";
getline(file,temp);
dictionary_words.push_back(temp);
}
}
//et cetera ...
|
In word.cpp, on the line "Word::Word(istream& file)", I get this error :' [Error] no matching function for call to 'Dictionary::Dictionary()'.
Im assuming it needs help to differentiate between Word's constructor and Dictionary's? If so, how do I do this?
If not, what is the reason for this error?
I am still relatively new to this, so forgive any other mistakes