Documentation Comments
Now that we can create reusable functions and procedures, we need a way to communicate to others the details on what the function or procedure is for and how to use it.
Many programming languages include the ability to add specifically formatted comments designed to help communicate these details. These allow you to provide a short summary for each function or procedure, along with details on its parameters and return values.
In C/C++
Documentation comments in C/C++ use the comment block syntax that starts with a /**
and ends with a */
. Within this block, you start by providing a summary of the function or procedure that follows, and then outline the parameters using the format @param name description
. For functions, you end with a comment that is formatted @returns description
, to describe what the function returns.
If you add these comments to your code in the header file, or above the declaration where ever it is, this will be picked up by VS Code and shown to you through the IntelliSense.
The following examples show how to comment a function and a procedure.