I have a header file that contains the following definition
const std::string error[] = {"a", "b"};
Now I'm including this file in two different translation units and compiling the source codes. Everything works, but why? This is expected to break one definition rule
.
Now even more interesting, I'm changing the type
const char* error[] = {"a", "b"};
and here it is, expected error
multiple definition of `error'
It works the same way as for std::string for int
, char
, short
and other integral types. What is this?