Warnung: non-static data member-Initialisierungen nur mit -std=c++11 oder -std=gnu++11?

Habe ich diesen code

class Move
{
    public:
        Move()
        {
            name = "";
            type_num = 18;
            power = 0;
            accuracy = 0;
            type = "???";
        }

        Move(string a, int b, int c, int d)
        {
            name = a;
            type_num = b;
            power = c;
            accuracy = d;
            /*lines of code to give type a string variable depending on the value of type_num*/
        }

    private:
        string name, type;
        int type_num, power, accuracy;
};

class Moveset
{
    public:
        Moveset()
        {
        }               
    private:
        Move slot1{"MOVE 1", rand() % 18, 10*(rand() % 15 + 1), 5 * (rand() % 11 + 10)};
};

Und der compiler hat mir diese Warnung für das Objekt deklarieren slot1 unter den private-Abschnitt der Klasse Moveset.

464 83  C:\Users\N\Desktop\C++\Poke\Poke.cpp    [Warning] non-static data member initializers only available with -std=c++11 or -std=gnu++11
464 15  C:\Users\N\Desktop\C++\Poke\Poke.cpp    [Warning] extended initializer lists only available with -std=c++11 or -std=gnu++11
464 83  C:\Users\N\Desktop\C++\Poke\Poke.cpp    [Warning] extended initializer lists only available with -std=c++11 or -std=gnu++11

Obwohl es gab mir die Warnung, aber anscheinend ist es nicht Einfluss auf das Programm ausgeführt wird. Tut es eigentlich auf irgendetwas? und was mache ich hier falsch?

Edit: Und was ist die diifference zwischen einer statischen member-Initialisierung und nicht-statische member-Initialisierung?

InformationsquelleAutor nayfaan | 2015-10-21

Schreibe einen Kommentar