How do you declare arrays in a c++ header?

后端 未结 3 1092
天涯浪人
天涯浪人 2021-02-04 01:18

This is related to some other questions, such as: this, and some of my other questions.

In this question, and others, we see we can declare and initialise string arrays

3条回答
  •  萌比男神i
    2021-02-04 01:39

    The reason you can't declare your array like that (const char* []) is that:

    • you can't have initializers in the class declaration, and so
    • the syntax const char* [] does not state how much space the compiler needs to allocate for each instance (your array is declared as instance variable).

    Besides, you probably want to make that array static, since it is in essence a constant value.

提交回复
热议问题