Compilation error

C

Chris Peters

Hi,

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.

Any advice?

Thanks.
 
S

Sjouke Burry

Chris said:
Hi,

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.

Any advice?

Thanks.
Should you not ask on a c++ group?
In c no new() and delete() unless you write them.
 
A

Antoninus Twink

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).
 
C

CBFalconer

Chris said:
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.

Any advice?

Yes. Ask on a newsgroup that deals with your language. This is
not it. We deal with C here. However the readers of comp.lang.c++
do handle that (assumed yours) language.
 
M

Martin Ambuhl

Chris said:
Hi,

I want to make the delete() operator private for my class
[etc.]

You need to find out what language you are using before doing stuff like
that. "delete", "private", and "class" suggest that you are using C++.
For that language, not the one discussed in <you
want <news:comp.lang.c++>.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,249
Latest member
KattieCort

Latest Threads

Top