I’ve noticed, using visual studio 2003, that I can ‘comment out’ my comments to make them no longer be comments. This one needs an example:
If I have:
/* int commented_out = 0; */
I can comment out the /* and */ with // and code within the /* and */ is no longer ‘commented out’ (the text changes to non-comment color and the compiler treats it as code once again). Like so:
///* int commented_out = 0; //*/
I’ve found this is true for msvc 2003, is this normal C++ behavior or is it just a fluke that works with this compiler?
Yep, this is perfectly normal behavior. The C++ standard says that a
/*is the start of a comment block only if it itself is not commented out. I often use what you’ve written above to comment or uncomment a block of code by adding/deleting one character. A nice little trick for switching between two blocks of code, one of which is always commented out is:Now, delete one slash from the start, and it becomes
Not something to use in production code, but very useful for quick debugging changes.