Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: cannot specify explicit initializer for array

I'm using Visual Studios 2013 and I keep getting this error yet I don't understand why.

class CLI{
    string commands[2] = {"create", "login"};
public:
    void addCommand(), start(), getCommand(string);
};

The error:

error C2536: 'CLI::CLI::commands': cannot specify explicit initializer for arrays
like image 865
Ethan Avatar asked May 27 '14 22:05

Ethan


1 Answers

Visual Studio 2013 is not completely C++11 compliant, so, like Tobias Brandt said, you'll need to use a constructor to initialize those members.

Braced init lists are a C++11 feature.

like image 114
Maple Avatar answered Sep 30 '22 06:09

Maple