Re: [GD-Windows] memory leak?
Brought to you by:
vexxed72
From: Mickael P. <mpo...@ed...> - 2002-11-07 13:14:03
|
Colin Fahey wrote: > [...] > I have three wild guesses about what you might be > observing: > > [A] Best guess: You are doing "new" and "delete" > on a regular "struct", instead of a "class". > This may simply allocate raw bytes with the > same size as your structure. This means that > the "std::vector<float> array" member is NOT > CONSTRUCTED, but is simply given space to exist. > Even though C++ compilers may implement > "struct" as "class", I don't know if "new" will > CONSTRUCT members of a "struct". > Anyhow, I'm guessing that the "delete" calls > aren't calling the destructor of the "array" > object within the "struct" (TestObj). > > EXPERIMENT: > Change the "struct" to "class" (TestObj), and > just add "public:". Don't make any other changes. > > [...] There is absolutely no difference in C++ between class and struct, except the fact that class are private by default, and struct are public by default. Construction/destruction behavior should be the same. Mickael Pointier |