Hello #TC1017, this is #Mastery07
Photo Credit: Graffyc Foto via Compfight cc
Comments in C++ are normally used to annotate code for future reference. The compiler treats them as white space. You can use comments in testing to make certain lines of code inactive.
To do that, there are two ways to comment in C++. You can use “/*” (slash, asterisk) to comment everything, including new lines; to make the end of everything that you wanna comment it must ends with “*/”. For Example:
#include <iostream>
using namespace std;
int main() {
cout << "hello world" << endl;
/*This is the text that
I wanna
comment*/
return 0;
}
Another way to comment is with “//” (two slashes). If you put double slash you’ll comment on your code only the single line. Example:
#include <iostream>
using namespace std;
int main(){
cout << "hello world" << endl; //This is a comment
This is not a comment
return 0;
}
In this page you can find more infor about this topic.
Use of comments in C++ by Gonzalo Mata is licensed under a Creative Commons Attribution 4.0 International License.