Új hozzászólás Aktív témák

  • WonderCSabo

    félisten

    válasz kmisi99 #1620 üzenetére

    Elnézést, az aposztróf közé rakás nem volt hiba, csak siettem és megzavart a ch változó neve...

    #include<iostream>
    #include<fstream>
    #include<string>

    using namespace std;

    class Dictionary
    {
    private:

    char alphabet;
    string meaning;
    string word;

    public:

    void getmeaning(std::string *p);

    void search()
    {
    string word;

    cout<<"enter a word :";
    cin>>word;

    getmeaning(&word);
    }
    } di;



    void Dictionary::getmeaning(std::string *p)
    {
    string a,b;

    // Assume there exists a dictionary dic.txt
    // Remember to add proper error handling (file operation)
    ifstream get("dic.txt",ios::in);

    while ( !get.eof())
    {
    get>>a>>b;

    if (*p==a)
    {
    cout<<a<<" "<<b;
    }
    }
    }



    int main()
    {
    int ch;


    cout<<"=D=I=C=T="<<endl;
    cout<<"1.Show meaning"<<endl;
    cout<<"2.Show word"<<endl;
    cout<<"3.Exit"<<endl;
    cin>>ch;

    switch(ch)
    {
    case 1:
    di.search();

    break;
    case 2:
    {
    string word;

    cout<<"enter a word :";
    cin>>word;

    di.getmeaning(&word);

    break;
    }

    case 3 :
    return 0;
    }

    return 0;
    }

    Leírtam előző hszemben az összes hibát, és a javításokat is. Lemásolsz egy kódot, más leírja, hogyan javíthatod ki, és még az se megy?...

    proci985: Nem, nem kell neki default, hibákért lásd előző hszemet.

Új hozzászólás Aktív témák