Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Code this using C++ and comment on each section to understand the code. Other attachments include: My header files DEntry.h and Dictionary.h, which you may
Code this using C++ and comment on each section to understand the code.
Other attachments include:
- My header files DEntry.h and Dictionary.h, which you may use in full, as a starting point, or not at all
DEntry.h /* Instructor solution for Program 2: Dictionary Dictionary entry class (DEntry) definition */ #ifndef DEntry_h #define DEntry_h #include using std::string; #include using std::ostream; class DEntry { public: void writeEntry(string w, string p, string d); // Write data to entry void printEntry(ostream &out); // Print contents of entry string getWord(); // Access word private: string word; // Word string part; // Part of speech string defn; // Definition }; #endif // DEntry_h
Dictionary.h
/* Instructor solution for Program 2: Dictionary Dictionary class definition */ #ifndef Dictionary_h #define Dictionary_h #include using std::ostream; #include "DEntry.h" // Implicitly includes class Dictionary { public: Dictionary(); bool addWord(string w, string p, string d); // Add word to dictionary bool addFile(string fname); // Add file contents to dictionary // Both functions return true if successful bool find(DEntry &entry, string word); // Find entry containing word void printAll(ostream &out); // Print all entries void printLetter(ostream &out, char letter); // Print all entries with word starting // with letter private: DEntry entries[100]; // Array of dictionary entries unsigned size; // Number of entries currently in dictionary unsigned posn(string w); // Position in which word w either exists or should be placed }; #endif // Dictionary_h
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started