Writing Good Comments
// Good (Comments)
Function Level Comments
These should be placed immediately before the function prototype they are describing in a header file.
Inline Implementation Comments
Sometimes it is necessary to explain a particularly complex statement or series of statements. In this case, you should use inline comments, placed either immediately before or trailing the line or lines in question. In general, prefer placing such comments before offending lines, unless the comment is quite short. These comments should start with a // followed by a space. If they are placed trailing a line, they should be separated from the end of the line by one space.
Notes to Other Developers (Or Yourself)
When writing code, it can sometimes be useful to leave notes to other developers or to yourself in the future. Examples of these include:
// TODO: something that should be done
// NOTE: a note about something in the code
Notes starting with these keywords (case sensitive) can be automatically highlighted by installable extensions on VSCode.
Teams Contributed to this Article:
Last updated
Was this helpful?