I have defined a global variable in my C++ class as follows :
std::string VAR = "HELLO_WORLD";
But cpplint is telling me :
Static/global string variables are not permitted. [runtime/string] [4]
Do you have an idea why ?
I have defined a global variable in my C++ class as follows :
std::string VAR = "HELLO_WORLD";
But cpplint is telling me :
Static/global string variables are not permitted. [runtime/string] [4]
Do you have an idea why ?
Copyright © 2021 Jogjafile Inc.
For the avoidance of doubt the language itself permits this.
Essentially though the static analyser you are using forbids this because
std::stringcontains a constructor so the statement actually "does something".Therefore it needs to be inside a function, not at global scope.
On the other hand,
is emitted, since that's no more than an assignment of a read-only
const char[]literal to an appropriate pointer.