Re: FACTORIAL PROGRAM
On Apr 17, 11:12 pm, Ian Collins <ian-n...@hotmail.com> wrote:
Marcus Kwok wrote:
In comp.lang.c++ per9000 <per9...@gmail.com> wrote:
In C++ and C# I tend to add an extra line before and after so that the
comments show (for some reason I do not use the /* ... */ style in C++
or C#):
//
// this loop does something to j
//
for (...)
--j;
One reason for not using the /* ... */ comments is that comments do not
nest (for example, when commenting out a piece of code):
Why bother commenting it out? Just delete it and use your editor's undo
or SCM to get the code back if you want it.
You might have other changes that you don't want to show up in
SCM before you've tested them. And your editor's undo will
typically get lost if the machine crashes in the meantime.
Still, writing the current state to a separate file before
editing it shouldn't be that difficult.
On the other hand, it might be worth commenting out if you
precede the commented out part with something like:
// This doesn't work because...
If the commented out code is significantly simpler than what you
replace it with, you can be sure that in the absence of such a
comment, some maintenance programmer will reinvent it, to
simplify, and whatever bug you just fixed will reappear.
Of course, for this sort of commenting out, you want real
comments, that look like comments, and not #if 0.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34