Comments denote pieces of text that are ignored by the compiler. The primary purpose of comments are to make the compiler ignore some piece of code during debugging, or to document the purpose of your code (for your sanity, and for making it obvious what's happening when sharing your code with others).
In VC, two styles of comments are supported: line comments (//) and block comments (/* ... */).
- Line comments: If you type a double slash (//) in your code, everything on that line after the slashes will be ignored.
void DexterJoin() { AddPlayer(3); }
Block comments: The second method of commenting is to use /* and */. When the compiler encounters a /*, everything will be ignored until it sees a */. Example:
void DexterJoin() { /* This is the part where Dexter joins after being seen on the path of Jujube mountains. The event below is number 75. */ addcharacter(3); }
/* ... */ comments don't nest, so putting one inside another one will not work as intended:
/* This is a test. /* This is a nested comment */ After that comment, everything here is an error. */
The // is preferred for simple phrases that you wish commented, while the /* */ method is best for large areas of text to be left commented.
Helpful Tip: Try using commenting if you have a problematic area of your VC code that refuses to compile. Use comments around parts that are creating errors, and try recompiling until you can isolate the problem.