i want define string constant can used various classes. created header file , added:
namespace myconstants { extern const char* constant1 = "somestring"; } this header gets included in several .cpp files access string.
this gives me following linker error:
fatal error lnk1169: 1 or more multiply defined symbols found
how need change string's declaration make linker error go away?
you need value defined in 1 translation unit, , leave pure declaration in headers.
namespace myconstants { extern const char* constant1; } and in 1 translation unit:
namespace myconstants { extern const char* constant1 = "somestring"; }
Comments
Post a Comment