[Tutor] small program in Python and in C++
alan.gauld@bt.com
alan.gauld@bt.com
Wed, 3 Jul 2002 18:07:02 +0100
> up writing a C++ equivalent for someone else a few minutes
>
> ...or if anyone cared to point out other ways
Not so much other ways but I notice you define your variables
in C++ just before using them.
That's a recipe for disaster! If you write more than a few
hundered lines of code finding your definitions will be murder.
Imagine discovering that a certain int has to be made a long.
Now find where within several hundred lines you declared it.
Ok you can use search functions but it's much easier to just
go to the top of the function!
Its much more maintainable to group declarations at the
top of the containing scope(function/file etc). The only
reasonable exception to this are single letter variablers
used as loop counters etc.
Others might disagree but I think most regular C++'ers
will back this up.
Alan G.