| | Submitted on: 9/21/2000 9:36:38 AM
By: Amin Patel1
Level: Beginner User Rating:
By 34 Users Compatibility:C++ (general), Microsoft Visual C++, Borland C++, UNIX C++
Users have accessed this article 21990 times. | (About the author) |
| | This tutorial has been made for new c++ programmers. Unfortunately their are many great minds out there but they don't have access to free and quality c++ tutorials. | |
|
Terms of Agreement:
By using this article, you agree to the following terms...
1) You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description. |
|
Planet
Source Code -
Start with a prayer to God, that you
“Succeed in learning C++" |
|
|
Only at PS Code
-
Code of the Day
To join the 'Code
of the Day' Mailing List click
here!
Thank you for coming to Planetsourcecode |
|
|
|
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 pr
// ogram 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:
- C
Style:
/*
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.:
- #include
<iostream.h>
- int
main()
- {/*
- cout<<
“ This whole line gets, commented
out!”;*/
- }
|
<Warning:
The numbered indentation is not to be included with
the code while typing. It is only for your
convenience>
- C++
Style
//
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.:
- #include
<iostream.h>
- int
main()
- {
- cout<<
“How are you I am fine”;
- //
Line 4 will print
- //“How
are you I am fine, to the screen.
- //
Notice that
- //I
placed the 2 slashes on this line too.
- }
|
|
|
|
|
Note:
If anything appears wrong, it is due to the incompatibility
of the browser. |
For compiler compatibility issues
please refer to tutorial
3 |
Users
of Netscape have complained regarding misprinting of C++
style comments but I can't verify that since I use IE, but
kudos to the Netscape user helping me solve the endless
comments problem due to browser incompatibility.
|
|
|
|
|
<-- content_end-->
|
|
|
| |
Other 3 submission(s) by this author
|
|
|
Report Bad Submission |
|
|
Your Vote! |
See Voting Log |
|
Other User Comments |
9/21/2000 5:43:15 PM:krane keep these tutorials coming!@#@! this
is what i have been looking for and im
sure alot more people are too@#@!
|
9/21/2000 10:56:31 PM:Amin Patel Thank you very much!
|
10/5/2000 10:43:52 PM:Ian Ippolito I've just removed a slew of off-topic
comments.
Ian
PSCode Admin
|
10/8/2000 9:30:58 PM:Sebastian Very nice and clean article, just can't
wait until the little more advanced
stuff comes :-)
|
10/9/2000 9:34:16 AM:Koeter Nice Tut ! I#d like to see more :o)
|
10/16/2000 10:21:00 AM:Roland Nice tutorial. I am not new to
programming, but I am new to C++. The
few books I've picked up on the subject
are indepth, but lack the 'being
schooled' programmer's perspective.
Keep up the good work and I'll be
tuning in for future tutorials!
|
1/21/2001 7:59:24 PM:Craig Good approach for beginners!
Your
tutorial taught me how to use my
command-line compiler (although I now
use Dev-C++[great IDE])
I think some
links would be helpful, as well as some
terminology so the people you start off
can learn more.
PS. do you know of a
good non-MFC Win32 API tutorial?
|
1/21/2001 8:01:46 PM:Craig Good approach for beginners!
Your
tutorial taught me how to use my
command-line compiler (although I now
use Dev-C++[great IDE])
I think some
links would be helpful, as well as some
terminology so the people you start off
can learn more.
PS. do you know of a
good non-MFC(vc++) Win32 API tutorial?
|
9/25/2001 9:03:28 PM:Daza These tutorials r great i have learnt
stacks. keep them coming. 10/10
Daza
|
10/1/2001 7:54:17 AM:Tore Thanks for the tutorial.
"Moo i am a
flying cow mooo", .
|
11/11/2001 3:09:14 PM:imn0thing this tutorial does nothing but show how
to use comments. and besides that,
your explanation is ridiculously poor.
why are people voting anything above 1
for your tutorials?
|
7/13/2002 10:20:06 AM:john gibson I have done a fair bit of c and vb and
am now about to learn c++. I've already
started reading and experimenting a bit
and with my knowledge of c, there was
nothing new here for me. However, this
is a fact, not a negative comment. It
seems amazing to me how a school pupil
can give an outline of the basics in
such a clear and concise way where many
(or almost all) of the books I've
looked at are so confusing. This will
be a great help for those without
pre-existing knowledge of c or c++.
Well done.
|
|
Add Your Feedback! |
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.
NOTICE: The author of this article has been kind enough to share it with you. If you have a criticism, please state it politely or it will be deleted.
For feedback not related to this particular article, please click here. |
|