home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / tcpp / examples / def.cpp < prev    next >
C/C++ Source or Header  |  1990-06-09  |  591b  |  30 lines

  1. // def.cpp: Implementierung der Definitionsklasse
  2. // aus Kapitel 6 der Einführung
  3.  
  4. #include <string.h>
  5. #include "def.h"
  6.  
  7. void Definition::put_word(char *s)
  8. {
  9.    word = new char[strlen(s)+1];
  10.    strcpy(word,s);
  11.    nmeanings = 0;
  12. }
  13.  
  14. void Definition::add_meaning(char *s)
  15. {
  16.    if (nmeanings < Maxmeans)
  17.    {
  18.       meanings[nmeanings] = new char[strlen(s)+1];
  19.       strcpy(meanings[nmeanings++],s);
  20.    }
  21. }
  22.  
  23. char * Definition::get_meaning(int level, char *s)
  24. {
  25.    if (0 <= level && level < nmeanings)
  26.       return strcpy(s,meanings[level]);
  27.    else
  28.       return 0;
  29. }
  30.