Here is an example by author:
/* Filename: diction.cpp
Author: Br. David Carlson
Date: July 14, 1999
Last Revised: December 23, 2001

This interactive program creates a map (table), where each entry
is a pair containing a word and its definition. Thus the map is
a small dictionary. The program then allows the user to repeatedly
look up the meaning of words.

In the code, change CTRL z to CTRL d for Linux.

and the website if your keen to see the real code....

and finally the code with the small change I made that gave me an error at line number 88...I don't understand why the compiler wont compile. All I did was add another member to the private section called recNum. The error says that it cannot convert char[] to class LineClass...


#include <iostream>
#include <map>
using namespace std;

const int LineMax = 72;

const int NULLCHAR = '\0';

typedef char LineType[LineMax];

class LineClass
	  LineType Info;	
	  int recordNum;
      LineClass(LineType Str, int recNum);
      void GetLine(LineType Line) const;
	  int  GetRecordNum() const {return recordNum;};

   Info[0] = NULLCHAR;
   recordNum = 0;

LineClass::LineClass(LineType Str, int recNum)
:	recordNum(recNum)
   strcpy(Info, Str);

void LineClass::GetLine(LineType Line) const
   strcpy(Line, Info);

bool operator<(LineClass LHS, LineClass RHS)
   LineType Left, Right;


   if (strcmp(Left, Right) < 0)
      return true;
      return false;

// Function prototypes:
void LoadData(map<LineClass, LineClass> & Dictionary);
void Lookup(LineType Target, map<LineClass, LineClass> & Dictionary);

int main(void)
   map<LineClass, LineClass> Dictionary;
   LineType Target;


   // Change to CTRL d for Linux:
   cout << "Enter word to look for (or CTRL z to quit): ";
   cin >> Target;
   while (!
      Lookup(Target, Dictionary);
      // Change to CTRL d for Linux:
      cout << "Enter word to look for (or CTRL z to quit): ";
      cin >> Target;

   return 0;

void Lookup(LineType Target, map<LineClass, LineClass> & Dictionary)
   map<LineClass, LineClass>::iterator p;
   LineType Meaning;
   p = Dictionary.find(LineClass(Target));      // <===========LINE88
   //p is pointing to the found target object
   if (p != Dictionary.end())
      p->second.GetLine(Meaning); //second is the mapped value so the mapped value is also a class.
      cout << "Meaning is: " << Meaning << endl;
      cout << "Word not found" << endl;

void LoadData(map<LineClass, LineClass> & Dictionary)
//the dictionary is holding a list/map of lineClass'es
   // Note the 2 different ways of creating a pair to insert:
   Dictionary.insert(pair<LineClass, LineClass>(LineClass("hot", 1),
      LineClass("having a high temperature", 1)));
      LineClass("having a low temperature" ,1)));
   Dictionary.insert(make_pair(LineClass("jog" ,1),
      LineClass("run slowly", 1)));
   Dictionary.insert(make_pair(LineClass("intelligent", 1),
      LineClass("smart", 1)));
   Dictionary.insert(make_pair(LineClass("register" ,1),
      LineClass("a high-speed storage location on a computer's CPU chip", 1)));