Saturday 20 April 2013

Comment to End of Line

a += 6; // this is a comment
The new style comments are useful as it is possible to comment out code containing
comments, e.g.
// a += 6 // this is a comment
// b += 7;
With C style comments (which are still available in C++) problems occur:
/*
a += 6; /* this is a comment */
b += 7;
*/
The close comment symbol in the original comment ends the new comment, leaving code
uncommitted and a */ symbol which will cause the compiler distress.

No comments:

Post a Comment