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:
/* You can write anything that makes sense here */
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.
E.g.:
|
<Warning: The numbered indentation is not to be included with the code while typing. It is only for your convenience>
// After the 2 slashes, you can type anything that makes sense.
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.
E.g.:
|
_______________________________________________________________________
I plan to write more tutorials when I can dedicate some time after school. If you like this code please give me a good message. I do need messages occasionally like “Thanks”, with all the pressure I face from school. If you have gained some knowledge from this tutorial please make me happy, by giving me an “excellent rating”
Add your tutorials to this site Mail Me