Why is “static” needed for a global const char but not for a bool?

前端 未结 2 1913
抹茶落季
抹茶落季 2021-01-01 19:45

Shared header.

I can do this:

const bool kActivatePlayground=false;

Works fine when included among multiple files.

I cannot do t

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-01 20:24

    You can use a constant char array

    const char kActivePlayground[] = "kiddiePool";
    

    and kActivePlayground can also be used for assignment because it is a reference

    const char* playground_text = kActivePlayground;
    

提交回复
热议问题