편집 기록

편집 기록
  • 프로필 유동욱님의 편집
    날짜2020.06.14

    C++ 인수 목록이 일치하는 생성자의 인스턴스가 없습니다.


    #include <iostream>
    #include <vector>
    #include <string>
    #include <list>
    #include <algorithm>
    
    using namespace std;
    
    enum Menu { continent_search = 1, hwak, die, wanchi, EXIT };
    enum Menu2 { continent_choice = 1, GO_MAIN };
    
    class country
    {
    public:
        string name;
        int hwakjin, die, wanchi;
        country(string name, int hwakjin, int die, int wanchi) {
            this->name =  name;
            this->hwakjin =  hwakjin;
            this->die = die;
            this->wanchi = wanchi;
    
        }
        bool operator <(country& country) {
    
            return this->hwakjin > country.hwakjin;
            return this->wanchi > country.wanchi;
            return this->die > country.die;
        }
    };
    
    
    class Covid
    {
    private:
    
        country countries[9] = {
           country("한국",4,1,1),
           country("중국",8,3,4),
           country("일본",6,7,8) }; // 오류가 생기는 부분 
    
    
    public:
    
    
        Covid() {}
    
        int showhwak(void)
        {
            sort(countries, countries + 3);
            for (int i = 0; i < 3; i++)
            {
                cout << countries[i].name << "사망자" << countries[i].hwakjin << endl;
            }
            return 0;
        }
        void showTitle()
        {
            cout << "코로나 확진자 현황\n";
        }
    
        void showMenu()
        {
            cout << "==================\n";
            cout << "1. 대륙검색\n";
            cout << "2. 확진자수\n";
            cout << "3. 사망자수\n";
            cout << "4. 완치자수\n";
            cout << "5. 종료\n";
            cout << "==================\n";
        }
    
        void showcontinentmenu()
        {
            cout << "==================\n";
            cout << "1. 아시아\n";
            cout << "2. 아프리카\n";
            cout << "3. 메인으로\n";
        }
    
        void continent()
        {
            while (true) {
    
                showcontinentmenu();
                int menuNum = inputMenu();
                switch (menuNum) {
                case continent_choice:
                    asia();
                    break;
                case GO_MAIN:
                    return; break;
                default:
                    break;
                }
            }
        }
    
        int inputMenu() {
            int menuNum = -1;
            cout << "입력>>";
            cin >> menuNum;
            return menuNum;
        }
    
        void _exit() {
            exit(0);
        }
    
        void asia()
        {
            string name;
            int temp;
            cout << "아시아 나라를 입력하세요:\n";
            cin >> name;
            for (int i = 0; i < 3; i++) {
                if (name == countries[i].name)
                    i = temp;
            }
            cout << countries[temp].name << "사망자" << countries[temp].hwakjin << "확진자" << countries[temp].wanchi << endl;
        }
    
        void showsamang()
        {
    
    
        }
        void showwanchi()
        {
    
    
        }
    
        void showcountry()
        {
    
        }
    
        void initialize()
        {
            showTitle();
            while (true) {
                showMenu();
                int menuNum = inputMenu();
    
                switch (menuNum)
                {
                case continent_search:
                    continent();
                    break;
                case hwak:
                    showhwak();
                    break;
                case EXIT:
                    _exit();
                    break;
                default:
                    break;
    
                }
            }
        }
    };
    
    int main()
    {
        Covid covid = Covid();
        covid.initialize();
    }
    

    오류가 생기는 부분에서 country countries[9]중 []안에 9를 지워주면 불완전한 형식이라고 에러가 발생하고 9를 써주면 C++ 인수 목록이 일치하는 생성자의 인스턴스가 없습니다. 라는 에러가 발생하는데 뭐가 문제인 걸까요 ㅠㅠ

  • 프로필 고영준님의 편집
    날짜2020.06.13

    C++ 인수 목록이 일치하는 생성자의 인스턴스가 없습니다.


    include

    include

    include

    include

    include

    using namespace std;

    enum Menu { continent_search = 1, hwak, die, wanchi, EXIT }; enum Menu2 { continent_choice = 1, GO_MAIN };

    class country { public: string name; int hwakjin, die, wanchi; country(string name, int hwakjin, int die, int wanchi) { this->name = name; this->hwakjin = hwakjin; this->die = die; this->wanchi = wanchi;

    }
    bool operator <(country& country) {
    
        return this->hwakjin > country.hwakjin;
        return this->wanchi > country.wanchi;
        return this->die > country.die;
    }
    

    };

    class Covid { private:

    country countries[9] = {
       country("한국",4,1,1),
       country("중국",8,3,4),
       country("일본",6,7,8) }; // 오류가 생기는 부분 
    

    public:

    Covid() {}
    
    int showhwak(void)
    {
        sort(countries, countries + 3);
        for (int i = 0; i < 3; i++)
        {
            cout << countries[i].name << "사망자" << countries[i].hwakjin << endl;
        }
        return 0;
    }
    void showTitle()
    {
        cout << "코로나 확진자 현황\n";
    }
    
    void showMenu()
    {
        cout << "==================\n";
        cout << "1. 대륙검색\n";
        cout << "2. 확진자수\n";
        cout << "3. 사망자수\n";
        cout << "4. 완치자수\n";
        cout << "5. 종료\n";
        cout << "==================\n";
    }
    
    void showcontinentmenu()
    {
        cout << "==================\n";
        cout << "1. 아시아\n";
        cout << "2. 아프리카\n";
        cout << "3. 메인으로\n";
    }
    
    void continent()
    {
        while (true) {
    
            showcontinentmenu();
            int menuNum = inputMenu();
            switch (menuNum) {
            case continent_choice:
                asia();
                break;
            case GO_MAIN:
                return; break;
            default:
                break;
            }
        }
    }
    
    int inputMenu() {
        int menuNum = -1;
        cout << "입력>>";
        cin >> menuNum;
        return menuNum;
    }
    
    void _exit() {
        exit(0);
    }
    
    void asia()
    {
        string name;
        int temp;
        cout << "아시아 나라를 입력하세요:\n";
        cin >> name;
        for (int i = 0; i < 3; i++) {
            if (name == countries[i].name)
                i = temp;
        }
        cout << countries[temp].name << "사망자" << countries[temp].hwakjin << "확진자" << countries[temp].wanchi << endl;
    }
    
    void showsamang()
    {
    
    
    }
    void showwanchi()
    {
    
    
    }
    
    void showcountry()
    {
    
    }
    
    void initialize()
    {
        showTitle();
        while (true) {
            showMenu();
            int menuNum = inputMenu();
    
            switch (menuNum)
            {
            case continent_search:
                continent();
                break;
            case hwak:
                showhwak();
                break;
            case EXIT:
                _exit();
                break;
            default:
                break;
    
            }
        }
    }
    

    };

    int main() { Covid covid = Covid(); covid.initialize(); }

    오류가 생기는 부분에서 country countries[9]중 []안에 9를 지워주면 불완전한 형식이라고 에러가 발생하고 9를 써주면 C++ 인수 목록이 일치하는 생성자의 인스턴스가 없습니다. 라는 에러가 발생하는데 뭐가 문제인 걸까요 ㅠㅠ