کلاس لیست لغات + عمل گر ها
کد:
#ifndef DICTIONARY_H
#define DICTIONARY_H
class Dictionary


    {
    public:
    Dictionary();
    ~Dictionary();
    void AddValue(char* key, char* val);
    void RemoveValue(char* key);
    void SetValue(char* key, char* val);
    char* GetValue(char* key);
    char* Dictionary::operator[] (char* key);
    bool Dictionary::operator> (Dictionary dict2);
    bool Dictionary::operator< (Dictionary dict2);
    bool Dictionary::operator>=(Dictionary dict2);
    bool Dictionary::operator<=(Dictionary dict2);
    bool Dictionary::operator!=(Dictionary dict2);
    bool Dictionary::operator==(Dictionary dict2);
    void Reset();
    private:
    char* vKeyVal[600][2];
    int nCurPointer;
};

Dictionary::Dictionary()


    {
    nCurPointer = 0;
}

Dictionary::~Dictionary()


    {
    Reset();
}

void Dictionary::AddValue(char* key, char* val)


    {
    vKeyVal[nCurPointer][0] = key;
    vKeyVal[nCurPointer][1] = val;
    nCurPointer += 1;
}

void Dictionary::RemoveValue(char* key)


    {
    for (int i = 0; i <nCurPointer; i++)


        {


            if (vKeyVal[i][0] == key) {
            vKeyVal[i][0] = "";
            vKeyVal[i][1] = "";
        }

    }

}

void Dictionary::SetValue(char* key, char* val)


    {
    for (int i = 0;i < nCurPointer; i++)


        {


            if (vKeyVal[i][0] == key) {
            vKeyVal[i][1] = val;
        }

    }

}

char* Dictionary::GetValue(char* key)


    {
    for (int i = 0;i < nCurPointer; i++)


        {


            if (vKeyVal[i][0] == key) {
            return vKeyVal[i][1];
        }

    }

    return "";
}

char* Dictionary::operator[] (char* key)


    {
    return GetValue(key);
}

bool Dictionary::operator> (Dictionary dict2)


    {
    return (nCurPointer > dict2.nCurPointer);
}

bool Dictionary::operator< (Dictionary dict2)


    {
    return (nCurPointer < dict2.nCurPointer);
}

bool Dictionary::operator>= (Dictionary dict2)


    {
    return (nCurPointer >= dict2.nCurPointer);
}

bool Dictionary::operator<= (Dictionary dict2)


    {
    return (nCurPointer <= dict2.nCurPointer);
}

bool Dictionary::operator!= (Dictionary dict2)


    {
    return (nCurPointer != dict2.nCurPointer);
}

bool Dictionary::operator== (Dictionary dict2)


    {
    return (nCurPointer == dict2.nCurPointer);
}

void Dictionary::Reset()


    {
    for (int i = 0; i < 100; i++)


        {
        vKeyVal[i][0] = "";
        vKeyVal[i][1] = "";
        nCurPointer = 0;
    }

}

#endif