Obteniendo un error en C ++

So Este patrón de is my code and I keep on getting este error. I don't know what it is. What I was doing before getting the error: Adding constructors and destructors to my classes. What the error seems to be: The error windows points to line 52, unsigned int _size; // number of account stored however I do not see anything wrong with the code.

preguntado el 01 de febrero de 12 a las 22:02

i can't see the error, but I think it is when you initialize the array [200] of AccountInfo. -

As you've posted it, the code won't (shouldn't) compile at all. Perhaps what you're compiling has added some the missing headers? If you're going to use C++, I'd advise using C++, and (for example) replacing your use of char *, strdup, strcmp, etc., con std::string. -

-1 for pasting your entire application's code. Please post short, self contained, correct (compilable) examples -

@Styne666 whenever I do that people just end up asking for the whole thing. It has happened before. -

1 Respuestas

One problem is that your AccountInfo class has a default constructor that doesn't initialize any of the pointers, but then its destructor wantonly calls free on those pointers. The best approach is to use std::string en lugar de char *, but if you're really insistent on using char *, then you at least need to initialize these pointers to NULL when they're not otherwise initialized.

That problem puede cause this assertion failure (since Visual Studio, in debug mode, will helpfully initialize these pointers to special, easily-recognized trap-values — one of its nicer features IMHO), but I haven't looked through enough of your code to see if you might have other similar problems that can Además, cause it, so I don't know if this problem is what is causing the failure. But you need to fix it, regardless.

Respondido 02 Feb 12, 02:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.