Charles Herman wrote:
> I have the following loop:
>
> for (int i = 0; i < n; ++i)
> {
> CClass newObject( i );
> //
> // lines of code
> //
> }
>
> Since a new object is being created (is it?) for every iteration, when is
> the previous object being destroyed, or is it? If not, how do I destroy
> it? Do I need to, if I don't will this lead to a memory leak?
>
Its created each time though the loop and each time through
too (closing brace). Can be a potential bottleneck,
particularly if it allocates any memory, but you won't know
for sure unless you profile it.
|