Kompilerproblem mit Klassen



  • Hi 😉
    Ich habe heute mal versucht, eine Art "Minesweeper" zu machen.
    Richtig weit bin ich jedoch nicht gekommen 😃

    #include <iostream>
    
    using namespace std;
    
    class tFeld
        {
          public:
            void SetFeld()
                {
                    for(int x=0; x < 20; x++)
                        {
                            for(int y=0; y < 20; y++)
                                {
                                    Feld[x][y] = ".";
                                }
                        }
                }
    
            void DisplayFeld()
                {
    
                    for(int y=0; y < 20; y++)
                        {
                            for(int x=0; x < 20; x++)
                                {
                                    cout << " " << Feld[x][y];
                                }
                            cout << endl;
                        }
                }
    
          private:
            char Feld[20][20];
        };
    
    int main()
    {
        tFeld Feld;
        Feld.SetFeld();
        Feld.DisplayFeld();
    }
    

    Nun bekomme ich beim kompilieren folgende Fehlermeldung:
    "In member function 'void tFeld::SetFeld()':
    error: invalid conversion from 'const char*' to 'char'"
    Fehler in Zeile 15
    Habe jedoch keine Ahnung wieso 😕
    Würde mich freuen wenn mit einer von euch helfen könnte
    ⚠ ! ⚠



  • Feld[x][y] = '.';
    


  • Oh mein Gott 😃
    Dankeschön 👍


Anmelden zum Antworten