i have a header file named calg.h which i hoped would contain a global name space, but no matter what i try, i keep getting redefiniton errors, either at compile time, or at linker time.
main.cpp include complex.h which includes calg.h. main.cpp then include term.h which in turn include calg.h. i get the linker error that alg:ossible_vars is already defined in complex.obj.Code://calg.h #ifndef CALG_H #define CALG_H namespace alg { //this could easily change and could be used throughout the entire program char possible_vars[] = "abcdefghijklmnopqrstuvwxyz" } #endif
i know that defining the variable in the header is not good (to the extent of which, i don't know)..but i tried creating a calg.cpp and .............................
i just had a thought - i didn't make it const ............be right back .................. ok, i placed a const before the definition/declaration of possible_vars and it compiled (or linked rather) just fine.
what gives?