I am trying to define an abstract overridable method isKnownWord(), i am recieving errors but i cannot see where they are coming from. Can any one enlighten me.
public:
spellChecker() {
wordList=NULL;
}
void addWord(char* aWord) {
int word_size=strlen(aWord) + 1;
char* dest=new char[word_size];
strcpy(dest,aWord);
wordRecord* newRec=new wordRecord;
newRec -> word=dest;
newRec -> next=wordList;
wordList=newRec;
}
void printDict() {
wordRecord* wordPointer = wordList;
while(wordPointer != NULL) {
printf("%s\n", wordPointer -> word);
wordPointer = wordPointer -> next;
}
}
public override bool isKnownWord() { // needs to be abstract and overridable
}
};
int main() {
char* words[] = {(char*)"hello", (char*)"Womble", (char*)"goodbye"};
char inputWord[80];
spellChecker * sc = new caseSensitiveSpellChecker();
for (int i=0; i<sizeof(words)/sizeof(char*); i++) sc->addWord(words[i]);
printf("Case sensitive dictionary contents:\n");
sc->printDict();
printf("Enter word ('END' to end): ");
scanf("%s", inputWord);
while (strcmp(inputWord, "END")) {
if (sc->isKnownWord(inputWord)) printf("yes\n");
else printf("no\n");
printf("Enter word ('END' to end): ");
scanf("%s", inputWord);
}
delete sc;
}
Your help would be greatly appriciated, i am eager to learn how to accomplish this.