Error: jump to case label



  • #include <windows.h>
    #include <string>
    #include <sstream>   
    
    // . . .
    
           case WM_PAINT:
                hdc = BeginPaint(hwnd, &ps);
                    TextOut(hdc, 0, 0, "Zahl", 4);
                    TextOut(hdc, 25, 0, "Quadrat", 7);
                    int iQuadrat;
                    string sOutput;
                    for (int i = 1; i < 31; i++) {
                        iQuadrat = i*i;
                        sOutput = toString(i);
                        TextOut(hdc, 0, maxCharHeight * i, sOutput.c_str(), sOutput.length());
                        sOutput = toString(iQuadrat); // Line 84
                        TextOut(hdc, 25, maxCharHeight * i, sOutput.c_str(), sOutput.length());
                    }
                EndPaint(hwnd, &ps);
            return 0;
    
            case WM_DESTROY: // Line 95
                PostQuitMessage(0);
            return 0;
        }
        return DefWindowProc(hwnd, message, wParam, lParam);
    }
    
    template <typename T>
    inline string toString(const T& number) {
        stringstream ss;
        ss << number;
        return ss.str();
    }
    

    Hallo, ich bin recht neu in WinAPI und versuche grade irgendwelchen Text auszu geben, als Übung halt :D.

    Bei meinem Codeschnipsel oben erhalte ich aber folgende Fehlermeldungen...

    95|error: jump to case label|
    84|error: crosses initialization of std::string sOutput'| 95|warning: destructor needed forsOutput'|
    95|warning: where case label appears here|
    95|warning: (enclose actions of previous case statements requiring destructors in their own scope.)|

    Habt Ihr vielleicht ne Idee?

    Dankeschön!



  • Hab das Problem gefunden, musste das ganze in einen scope setzen 😃


Anmelden zum Antworten