C++ Intro (Part 2) by Amin Patel
Before you learn something. Start with a prayer to God, that you “Succeed in learning C++”.
Almost every time the teacher gives lesson in school, we might copy everything from the board or make notes over what is taught. There is a similar thing we call in c++, ‘Comments’. Comments can be used for different purposes.
· The most obvious one, to recall the purpose of the code (Say you are referring to it after 6 months, makes less sense then. If you don’t include a comment.)
· Helps your computer teacher know what you have actually written. Just kidding.
· Now this one is an unobvious reason. Sometimes after compiling you might want to remove some line just to see how your program works then, without deleting the actual code.
· The final one, just a good programming style to express your thoughts.
Comments can be written anywhere in the program (Good Feature). They don’t effect your code, unless you comment out something by mistake.
There are two types of comments:
After the introduction of c++ it just become a norm for programmers to ‘Comment out’, huge parts of their code using this style. The initial part (/*) and the final part(*/) can be on separate lines.
<Warning: The numbered indentation is not to be included with the code while typing. It is only for your convenience>
This comment style is used more often these days but please note that if your comment sentence goes over many lines, please use // on each line at the beginning.
Add your tutorials to this site Mail Me
Copyright © 2001-04 [Gaurav Creations]. All rights reserved