Why const std::string str="__$HOOK_FUNC_FOR_LUA_KEY@__";
is ok whereas
the compiler complains when compiling
const std::string str("__$HOOK_FUNC_FOR_LUA_KEY@__");
?
NOTE: str
is a member variable of a C++ class.
Demo code:
class Demo
{
private:
const std::string str("__$HOOK_FUNC_FOR_LUA_KEY@__");
}
Here are the the error messages:
test.hpp:253:51: error: expected identifier before string constant
const std::string str("__$HOOK_FUNC_FOR_LUA_KEY@__");
^
test.hpp:253:51: error: expected ‘,’ or ‘...’ before string constant
It's obvious that there is ctor for std::string(char*)
. So I am really confused.