I am trying to find a way that I can define/initialize some static string arrays in a struct inside a class definition. These string arrays are always to be initialized with string literals. I tried doing the following and it initializes the parameterTypes[]
fine and i can access the strings using eg. MethodNaming_bla::parameterTypes[2]
, but if I pass the parameterTypes
as a const char* const * const
i get a linker error :( Also if i pass it to a constructor using MethodNaming_bla::parameterTypes
.
struct MethodNaming_bla
{
static constexpr const char* const parameterTypes[] = { "afd","qwer","zvc" };
static const char* const * const parameterTypes_d = parameterTypes;
};
However if i do the same in a function, it works for some reason.
int main(int, char* [])
{
static constexpr const char* const parameterTypes[] = { "afd","qwer","zvc" };
static const char* const * const parameterTypes_d = parameterTypes;
}
Is there a way where I can define and initialize a string array in a struct from string literals, inline?
Thanks in advance, Martin