John B. Matthews
8/14/2008 10:55:00 PM
On 14 Aug 2008 at 22:44, Chris Peters wrote:
> I want to make the delete() operator private for my class - I'm using
> reference counts, so I want to force users of my class to call my function
> rather than being able to delete and confuse the reference counter. But
> allocating memory with new() is OK.
>
> On VC++6 this works fine, but on VC++.NET it generates an error that
> making delete private causes memory leakage.
I think it should generate an error on both.
If the constructor throws an error, it needs to be able to access
delete. So if delete is private (or protected), you should only be able to
invoke new from a member function of the class (or a derived class).