The following source code is an example of the smallest C++ program you can write.
int main(){ }
The program doesn’t do much yet everything is there. Every C++ program must have one, and only one, main() function. The main() function must return an integer value. The value returned by the main() function is a result code intended for use by the operating system. The result code gives some indication of how the program terminated. Readers with some experience will note the absence of a return statement in the body of main(). A return statement is not necessary because the compiler does the job for you by default. You can compile and run this minimal program but on most computers you’d receive no indication it had executed.
int main(){ }
The program doesn’t do much yet everything is there. Every C++ program must have one, and only one, main() function. The main() function must return an integer value. The value returned by the main() function is a result code intended for use by the operating system. The result code gives some indication of how the program terminated. Readers with some experience will note the absence of a return statement in the body of main(). A return statement is not necessary because the compiler does the job for you by default. You can compile and run this minimal program but on most computers you’d receive no indication it had executed.
No Responses to "A Minimal C++ Program"
Leave a Reply