Hi,
On Wed, Aug 18, 1999 at 03:34:07PM -0700, Matthew D. Langston wrote:
>
> I saw a couple of problems with your C++ code that will definitely cause
> you problems.
Right, they will cause problems, but ...
> EMCalo::~EMCalo()
> {
> delete [] Modules;
> }
>
> You were using "delete Modules;", which the C++ Standard says will
> result in undefined behavior.
this is correct, but I found this error, too, and the problems
during reading the file still remain.
> An easy way to avoid problems like this (i.e. accidentally mixing your
> forms of "new", "new []", "delete" and "delete []") is to use the
> "auto_ptr" and "auto_array_ptr" class templates. I have attached my
> implementation of an "auto_array_ptr" class template to this e-mail
> which you may find helpful.
Thanks, I will have a look at it.
> The second problem is that you were calling "delete" on your ifstream.
> In your code you have:
This was only a typo when writing the mail. I realized, that I
forgot a close() statement in the code and entered automatically
also a delete. This code would never run and in my following
mail I had corrected this.
> FYI, whenever I get a segvio from cint, I always compile my code (not
> linking it, mind you), just to let the compiler catch my errors. Your
> C++ compiler would have caught the errors that I spotted by eye (there
> may be others that I didn't catch as well). Once the compiler is happy,
> my code typically runs just fine in the interpreter.
This is how I'm working in the meantime.
Best regards,
Volker
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:38 MET