devxlogo

Initializing a Static Array Member of a Class

Initializing a Static Array Member of a Class

You can initialize static arrays member of a class. The initialization must appear at the place of definition, not inside the class body. For example:

 class A{private: static char vars[2]; // declaration, can't initialize here//..};char A::vars[2] = {'a', 'b'}; // definition + initialization

size=3>

devx-admin

Share the Post: