You will have extra time to work on this lab since the midterm is this week.
For students with the Tuesday lab section, this lab is due on February 27.
For students with the Thursday lab section, this lab is due on March 1.
You will create a program that will "remember" definitions of words or phrases, it will do so by storing words/phrases and their associated definitions into a file named "definitions.txt".
Name your source file "define.cpp" and name your program "define" by compiling it with the following command:
g++ -o define define.cpp
If define is ran with 1 command-line argument, it will display the definition of that word/phrase specified by that argument. For example, if "definitions.txt" contained the definition "a named object" for "variable", then the command:
./define "variable"
would display:
a named object
If define is ran with 2 command-line arguments, it will create a new definition or replace an existing one in the file "definitions.txt". For example, the command:
./define "class" "a user-defined type"
creates a new definition for "class" and the command ./define "class" can now be used to look up that definition at a later time.
You may add informational messages to your program such as "Definition created.", "Definition updated.", or "Definition not found" but these are optional.
One way you can implement this program is to load the defintions from the file into a map<string, string>, from here the definitions can easily be queried and modified through the map. Before the program terminates, the updated definitions in the map should be saved to the file.