List 2-7 CDictionaryクラスの定義

  1: // 英和辞書データ
  2: struct EJ_Dictionary {
  3:     char Eword_dic[10];  // 英単語
  4:     char Jword_dic[10];  // 和単語
  5: } dic[] = {{"pen","ペン"}, {"pencil","鉛筆"},{"book","本"}};
  6: 
  7: // IDictionary インタフェースを継承したCDictionaryクラスの定義
  8: class CDictionary : public IDictionary
  9: {
 10: private:
 11:     ULONG    m_dwRef;    // 参照カウント
 12:     int      m_nWord;    // 単語数
 13: public:
 14:     HRESULT __stdcall    QueryInterface(REFIID iid, void** ppvObj);
 15:     ULONG   __stdcall    AddRef();
 16:     ULONG   __stdcall    Release();
 17:     HRESULT __stdcall    LookupWord(char* lpszEword, char* lpszJword, BOOL* pbResult);
 18:     CDictionary() : m_dwRef(0) { 
 19:         // 辞書の単語数を算出する
 20:         m_nWord = sizeof(dic)/sizeof(EJ_Dictionary);
 21:     }
 22:     ~CDictionary() { }
 23: };