| Comments | |
A comment is a line or paragraph of text in a file such that that line orparagraph is not considered when the compiler (or the parser) is decoding thecode of the file.
The C/C++ language accepts two types of comments:
// This are various examples of a one-line comment//---------------------------------------------------------------------------// Include the necessary libraries for a basic program#include <iostream>#include <conio>using namespace std;#pragma hdrstop//---------------------------------------------------------------------------#pragma argsused// Every C++ function must have a main() functionint main(int argc, char* argv[]){ // Display a simple sentence to the user cout << "Welcome to the wonderful world of C++ Programming!!!\n"; // Prompt the user to close the program cout << "\nPress any key to continue..."; // Let the user press a key to stop the program getch(); // The program went alright, so return 0 return 0;}//--------------------------------------------------------------------------- |
/* This are various examples of a forward slash asterisk comment *///---------------------------------------------------------------------------/* Include the necessary libraries for a basic program Because this program is intended for Borland C++ Builder, you should include the conio.h library that has the getch() function. */#include <iostream>#include <conio>using namespace std;#pragma hdrstop//---------------------------------------------------------------------------#pragma argsused/* Every C++ function must have a main() function The current C++ Standard recommends that the main() function return a value. In this case, it will return an integer. The main() function is the entry point of the program. This version of main() takes two arguments. Sometimes the arguments are not used at all, as is the case in this program.*/int main(int argc, char* argv[]){ // Display a simple sentence to the user cout << "Welcome to the wonderful world of C++ Programming!!!\n"; /* Because we are using Borland C++, we will explicitly prompt the user to press an key in order to stop the program. Upon pressing a key, we will call the getch() function to receive it */ cout << "\nPress any key to continue..."; getch(); // The program went alright, so return 0 return 0;}//--------------------------------------------------------------------------- |
| |
| Copyright © 2003 FunctionX, Inc. |
|
|