Memory management between pointer-object and non-pointer object


First of all.. I have some memory management problem in my source code.
I know the reason roughly. it is non-pointer object.
in some function using pointer-object, no problem is there.

I want to know how I can delete memory by allocated by non-pointer object ?

Could you post some code? I don't thing I understood your question.

thank you for your attention to my question.

Actually the situation is this..
class ABC{
...
};
int main()
{
ABC abc(1, 1); // just arbitrary parameters for constructor.
...
...
return 0;
}

in this source code, the constructed object "abc" is not deleted explicitly..
so..
If I constructed many objects, the executable program is not over without any memory trouble even though the outcome is correct.

I usually make many classes..
Some object is constructed as pointer type and no error is occurred in this cases.
(in this case, the destructor is called..)

that is, my point is how to memory de-allocator when I use non-pointer object ?

thank you ..
The destructor of abc will be called when the current scope is exited (i.e. when main is exited), since it is a so-called automatic object.

You'll have to explain why you think the destructor doesn't get called.
Last edited on
Local variables are allocated on the stack and are managed automatically. You don't call delete on them. Their destructors are called when they go out of scope.
if the memory is on the heap, you will prbly have to use a pointer in a higher scope to keep track of it...
Topic archived. No new replies allowed.