the following example shows the problem:

"int* pointername = new int"
followed by "delete pointername" - no problem.

however:
"int* pointername = new int[8]" followed by "delete pointername"
flags`an error during execution. (compile/built are passing ok).

This happens with 2 very different compilers: vc++ (native) and djgpp one.
looks like I am missing some thing in c++ in general.

I selected type *int but it coulds be any pointer type(pointer to a class for example).

Thanks for your attention
Uri.

Should work fine. The error is probably the result of something else in the code.

Can you post a small example of code that crashes?

You must delete array pointer by delete [] pointer operator.
In other words a pointer obtained from new[] must be deleted by delete [] .

Learn C++ more carefully ;) ...

commented: Thanks for the correction +11

In other words a pointer obtained from new[] must be deleted by delete [] .

Damn I totally missed the missing brackets..

Learn C++ more carefully .

I'll do that, thanks for the advice ;)

It was my free advice to uw1 ;)

Thanks ArkM,niek_e for the solution.:)
uw1.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.