편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2021.01.20

    C++ 클래스 배열 오류


    프로젝트과제로 쇼핑 프로그램을 만들고 있습니다. 상점리스트를 배열로 만들어, 상점이름과 통화를 배열에 저장하려고합니다.

    현재 상점이름을 입력하면 출력이 되는걸 확인하고 싶은데, 입력하고 바로 끝나버립니다. 어디가 문제인지 알려주시면 감사하겠습니다.

    프로젝트 코드가 너무 길어 문제가 되고있는 부분만 첨부했습니다.

    string shopTitle;
    string currency;
    
    int shopCount = 0;
    
    Shop *Shops[20];
    Shop *newShop;
    
    int main(){
    
        //내용생략 
        if (loginSelection == 2)
        {
            while(!Userlog){
                string _user,_pass;
                cout <<"Enter username: ";
                cin >> _user;
                cout <<"Enter password: ";
                cin >> _pass;
                if(checkUser(Sellers,sellerCount,_user,_pass)){
                    cout << "Welcome, "<<_user<<endl;
                    Userlog = true;
                    int shopPosition = getPosition(Sellers,_user,sellerCount);
    
                    // Shop * shop = Shops[shopPosition];
    
                        // if(shop->get_shop_name() == "" && shop->get_shop_currency() == ""){
                        cout << "select a name for your Shop\n";
                        cin >> shopTitle;
                        newShop->set_shop_name(shopTitle);
                        cout<< newShop->get_shop_name();
                        cout << "what currency do you accept in your Shop? USD/MYR etc.\n";
                        cin >> currency;
                        newShop->set_shop_currency(currency);
                        Shops[shopCount] = newShop;
                        shopCount++;
    
                    // }
    }
    
    
  • 프로필 알 수 없는 사용자님의 편집
    날짜2021.01.20

    C++ 클래스 배열 오류


    프로젝트과제로 쇼핑 프로그램을 만들고 있습니다. 상점리스트를 배열로 만들어, 상점이름과 통화를 배열에 저장하려고합니다. 현재 상점이름을 입력하면 출력이 되는걸 확인하고 싶은데,, 입력하고 바로 끝나버립니다.. 어디가 문제인지 알려주시면 감사하겠습니다,,프로젝트 코드가 너무 길어 문제가 되고있는 부분만 첨부했습니다,,

    string shopTitle;
    string currency;
    
    int shopCount = 0;
    
    Shop *Shops[20];
    Shop *newShop;
    
    int main(){
    //내용생략 
                          if (loginSelection == 2)
            {
                while(!Userlog){
                    string _user,_pass;
                    cout <<"Enter username: ";
                    cin >> _user;
                    cout <<"Enter password: ";
                    cin >> _pass;
                    if(checkUser(Sellers,sellerCount,_user,_pass)){
                        cout << "Welcome, "<<_user<<endl;
                        Userlog = true;
                        int shopPosition = getPosition(Sellers,_user,sellerCount);
    
                        // Shop * shop = Shops[shopPosition];
    
                            // if(shop->get_shop_name() == "" && shop->get_shop_currency() == ""){
                            cout << "select a name for your Shop\n";
                            cin >> shopTitle;
                            newShop->set_shop_name(shopTitle);
                            cout<< newShop->get_shop_name();
                            cout << "what currency do you accept in your Shop? USD/MYR etc.\n";
                            cin >> currency;
                            newShop->set_shop_currency(currency);
                            Shops[shopCount] = newShop;
                            shopCount++;
    
                        // }
    }