Comments are used to explain C++ code and make it more readable. Comments are ignored by the compiler. C++ supports:
//
/*
and end with */
#include <iostream>
using namespace std;
int main() {
// This is a single-line comment
cout << "Hello!" << endl;
/*
This is a multi-line comment.
It spans multiple lines.
*/
cout << "This is C++." << endl;
return 0;
}
Hello!
This is C++.
//
is used for single-line comments./* ... */
is used to write multi-line comments.