can someone help me complete this code please, on the ares i put comments please. thanks
#include <stdio.h>
#include <string.h>
class wordRecord {
public:
char* word;
wordRecord* next;
void printWord() {
printf("%s\n", word);
};
};
class abstractWordList {
private:
void printWordsHelper(wordRecord* wordRecPtr) {
if (wordRecPtr) {
// Code omitted to print the word list in reverse order.
// Your code should achieve this by calling printWordsHelper()
// recursively to print the remainder of the list THEN printing
// the current word.
//
// You need two statements:
// The first should call printWordsHelper(), passing the "next"
// pointer of whatever wordRecPtr points to as a parameter.
// The second should use the printWord() method to print out
// the word in the current wordRecord.
}
};
public:
wordRecord* wordList;
abstractWordList() {
wordList=NULL;
}
void printWords() {
// Print out all the words in the list
printWordsHelper(wordList);
};
bool containsWord(char* aWord) {
// Return true if aWord is contained in the list; false otherwise
wordRecord* wordRecPtr = wordList;
bool found=false;
// Code omitted to step through the word list, setting "found"
// to true if the required word is found
return found;
};
};
class nonUniqueWordList : public abstractWordList {
public:
virtual void addWord(char* aWord) {
// Add the word to the beginning of the list of words
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;
}
};
class uniqueWordList : public abstractWordList {
public:
virtual void addWord(char* aWord) {
// Code omitted to add the word to the beginning of the
// list in the same way as in the nonUniqueWordList method,
// but only if the list doesn't already contain the word.
// (Test this using the containsWord() method.)
}
};
int main() {
nonUniqueWordList* wl = new nonUniqueWordList();
char inputWord[80];
// Read in words from the keyboard and add them to the list
printf("Enter words:\n");
scanf("%s", inputWord);
while (strcmp(inputWord,"END")!=0) {
wl->addWord(inputWord);
scanf("%s", inputWord);
}
printf("Words entered:\n");
wl->printWords();
delete wl;
}