C++
Embed comment into source code.
in C++
Embed comment into source code. // handles string after // as comments.
// can be written after statement like function, assigning variable, etc...
/* - */ handles string included by /* */ as comments.
/* - */ can be embedded between statements.
/* - */ can handle multiple comment lines.
/* - */ can not be embedded into other /* - */.
comment.cpp
#include <iostream>
int main(void) {
// one line comment
std::cout << "one line comment can write after statement" << std::endl; // one line comment
/* This comment style can be written in multi lines like the following */
/*
line 1
line 2
*/
/* This comment style can be embedded in statement */
std::cout << "This statement line includes" /* comment */ "comment" << std::endl;
return 0;
}
Result
$ g++ comment.cpp -o comment
$ ./comment
one line comment can write after statement
This statement line includescomment