When do we need #ifdef before #undef?

See ISO C99 6.10.3.5 paragraph 2. A preprocessing directive of the form # undef identifier new-line causes the specified identifier no longer to be defined as a macro name. It is ignored if the specified identifier is not currently defined as a macro name. Even Visual C++ 6 (which was notorious for bad standards compliance) … Read more

Is usage of anonymous classes in Java considered bad style or good? [closed]

I tend to use anonymous inner classes in situations where I don’t need to have a full-blown class just to perform some task. For example, if I want to implement an ActionListener or Runnable, but I don’t think having an inner class would be necessary. For example, for starting a simple Thread, using an anonymous … Read more

Should I prefer private member functions, or functions in an unnamed namespace? [duplicate]

In the semi large projects where I usually work (more than 2 million lines of code) I would ban private class functions if I could. The reason being that a private class function is private but yet it’s visible in the header file. This means if I change the signature (or the comment) in anyway … Read more

Should you use const in function parameters, and why does it not affect the function signature?

const is pointless when the argument is passed by value since you will not be modifying the caller’s object. Wrong. It’s about self-documenting your code and your assumptions. If your code has many people working on it and your functions are non-trivial then you should mark const any and everything that you can. When writing … Read more