Original Post
Hi!
I have a very quick-to-answer-question. Does the following code lead to a crash?
The point is whether the function call of malloc or calloc(never mind) in a constructor is recommended or not.
I experienced a crash in my program, even before main-routine enters, and I use structs and classes similar to the above scheme. I can't locate the error, but I'm not sure if THAT might be the source of all evil or not...
Thanks in advance for your help!
Yours,
Indeterminatus
--si tacuisses, philosophus mansisses--
[edited by - Indeterminatus on May 27, 2002 4:26:16 PM]
struct my_struct
{
char *_a_string;
// Constructor
my_struct()
{
_a_string = (char *)calloc( 20, sizeof( char ) );
}
~my_struct()
{
free( (void *)_a_string );
}
};