Hello All,
I am working on writing a code to implement dictionary in C++. I have few functions to implement for my dictionary. Can someone please help me writing the definitions for my dictionary.
Header file and cpp file is attached here.
Dict.h file is as below:
enum WordType{All, Animal, Fruit, Name};
struct Word{
WordType type;
char word[20];
};
struct Dict{
int size;
int capacity;
Word **wordArray;
};
Dict *createDictionary(int capacity);
bool addWord(Dict *dic, const char *word, WordType type);
void deleteDictionary(Dict *dic);
void printDictionary(Dict *dic, WordType type=All);
Dict.cpp file is as below in which I need to add definitions:
#include "dict.h"
#include <cstring>
#include <iostream>
using namespace std;
Dict *createDictionary(int capacity){
//To do, initialize a dictionary with the specified capacity
}
bool addWord(Dict *dic, const char *word, WordType type){
//To do, add a Word to the dictionary. If the dictionary is already full, can’t add word and return false. Otherwise, add the word to the dictionary, increase dictionary size by 1, and return true.
}
void deleteDictionary(Dict *dic){
//To do, delete all words in the dictionary and then the dictionary
}
void printDictionary(Dict *dic, WordType type){
//To do, for default type all (specified in the header file), print words of all types. Otherwise print words of the specified types
}
Please help me asap. Thanks in advance.