[Tutor] small program in Python and in C++

Rob rob@uselesspython.com
Wed, 03 Jul 2002 13:20:14 -0500


Philosophically, I'm inclined to agree. Defining them all in a clump "up 
top" is the way we did it in Pascal back in '92, as I recall (although I 
could be wrong, it having been a decade back).

I've mainly gotten into doing it this way because my C++ professor and 
the books we use have a decided preference for doing it this way.

Rob
http://uselesspython.com

alan.gauld@bt.com wrote:

>>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.
> 
> 


-- 
"Giving the Linus Torvalds Award to the Free Software Foundation is a 
bit like giving the Han Solo Award to the Rebel Alliance."
--Richard Stallman at the 1999 LinuxWorld show