How to add Comments in C++
How to add Comments in C++
The C++ comments support single-line and multiple-line. All characters must be available inside any comment and always ignored by the compiler of C++.
Normally, C++ comments start with /* and end with */. For example:
/*This is my comment in single-line*/
/*This my comment in multiple-line
*C++ can also support for multiple-line
*/
/*This my comment in multiple-line
*C++ can also support for multiple-line
*/
We can also extending the comment at the of each line with //. For example:
#include<iostream>
using namespace std;
main(){
cout<<"Hello World!"; //Prints Hello World!
return 0;
}
When compile the source code above, the compiler will ignore //Prints Hello World!, So the final executable result will be produced the by following:using namespace std;
main(){
cout<<"Hello World!"; //Prints Hello World!
return 0;
}
Hello World!
Within a /* and */ comment and a // character have no special meaning. Mean that all of thus, you can 'hideaway' just one kind of comment. For example have shown above.
Learn more about C++, click here to view the table contents
Comments
Post a Comment