Re: [Dev-C++] Deliberate crashes - more information
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Bob W. <bo...@ph...> - 2002-04-09 01:20:07
|
MessageIoannis, It's all theoretical, you may try to place data in address you assume = allocated too. From my experience making it 0 doesn't protect you in = reality if you do not know what is going on. :) The last thing you will = do on a pointer assuming it points to allocated space is to delete it. = Before you will try to read/write from there (and boom even if it is 0). = So the real solution to such problems is to know what is going on in the = code.=20 Boy! Do I agree those two statements. Perhpas the most practical = demonstration of the importance of knowing what is going on in the code = is when you import a source code routine that someone else has written, = and there are problems with the either logic or the syntax. If you do = not understand the underlying algorithm and the coding, it is impossible = to fix the problem. It goes without saying that code that is written in = a clear, self-documenting style filled with enough comment to make the = code crystal clear.=20 For knowing what is going on, keep code separated inside small = functions each of one doing some specific job.=20 Again I could not agree more. Weveral years ago when the amount of = memory available for code space was limited either by the cost of ram or = software and hardware architectures, building many small functions was = not feasible because the overhead associated with such a metohdology = quickly filled and often overran the space available.=20 There are ways for bullet-proof code but it is not yet the time for = you to think of them, just keep learning and keep experimenting with C++ = as you are doing. And now we get back into an area of a potential disagreement. In = addition to teaching the syntax of a language, any teacher, tutorial, = book, etc., should make sure all of its examples are bullet proof, and, = where appropriate, methods of insuring that any code created with the = language feature under discussion should be discussed. Good langruage = specific programming practices should not be separated from the = fundementals of good code design.=20 |