std::string caveat

Never access an std::string‘s buffer with an intent to increase/decrease it’s length nor pass such a buffer to functions which takes a char*. I did this mistake sometime back and got trapped in a strange bug with operator +=. This is how my code looked. [sourcecode language=”cpp”]std::string str( ‘ ‘, MAX_PATH ); GetFolderName( pFullPath, &str[0] […]
Continue reading…

 

Variable value is always’s zero, no matter what you do!

Recently a friend of mine (sitting just behind me) had a strange problem. I wrote an inline function which was like… void SetBlah( const bool IsBlah ) { m_IsBlah = IsBlah; } Now he was using this function since we work for the same project! So he had a value 1 for IsBlah when calling […]
Continue reading…