Monday, January 31, 2011
const variables in headers and namespace !!
Hey today I suffered a lot while compiling my code in GNU C++.
What I did ? I have put a std::string variable in a header file inside a namespace
I was always getting variable multiple defined error, I almost broke my head in solving this simple problem.
header files were properly guarded !! (to avoid multiple inclusion)
Variable was declared in its own namespace !! (to avoid name collision)
Find | Grep used to check if the variable is declared anywhere !!
Ohh is it so i forgot C, C++ ? Is it so that I am writting more java now a days :)
Am I really a senior software engineer I doubt now !!
Ohhh Hell I left the const key word before the std::string object !
solution is const std::string A_VARIABLE_NAME and it is solved :)