arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -


simple question:

i'm trying initialize array within c++ class declaration:

using namespace std; #include <string> class myclass{ public:   string myarray[] = {"a","b","c"}; }; 

and i'm getting error:

error: brace-enclosed initializer not allowed here before ‘{’ token

no, without complied c++11 compiler, cannot initialize member array in declaration. have initialize array member in constructor. , don't use open array if know number of elements initialize array.


Comments

Popular posts from this blog

python - pip install -U PySide error -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -