maybe is stupid question but is there any way to write good looking (short ) format to write comments for c++ function,headers,variable ? any visual examples?
There are two ways to add comments in C: // - Single Line Comment. /*... */ - Multi-line Comment.
Single-line comments start with two forward slashes ( // ). Any text between // and the end of the line is ignored by the compiler (will not be executed).
1. A comment is text in a program's code, script, or another file that is not meant to be seen by the user running the program. However, is seen when viewing the source code. Comments help make code easier to understand by explaining what is happening and help prevent portions of a program from executing.
What do you mean by good looking here ? I do it like this ..
int c;//! loop Counter
/**
* compares (XOR) two Types
* return boolean result
*/
bool compare(Type l, Type r);
Its doxygen format. there are populer formats for documenting codes in Comment. Doxygen is one and another one is naturaldocs. there are even more. Its your flavour. You may even like the naturaldocs format.
/*
Function: Compare
Compares two Types
Parameters:
l - lhs
r - rhs.
Returns:
boolean result
*/
bool compare(Type l, Type r);
The DOC++ format is also similer like.
/** Comparison
Compare two Types
@param l Type lhs
@param r Type rhs
@return boolean result
*/
bool compare(Type l, Type r);
Just use only one format and stick with it.
I prefer using this style:
/**
* Class name
* Description
*/
class MyClass{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With