[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

Compilation error

Retoro

8/14/2008 10:45:00 PM

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.


4 Answers

Sjouke Burry

8/14/2008 10:52:00 PM

0

Chris Peters wrote:
> 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.

John B. Matthews

8/14/2008 10:55:00 PM

0

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

CBFalconer

8/14/2008 11:58:00 PM

0

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

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.a...
Try the download section.

Martin Ambuhl

8/15/2008 12:07:00 AM

0

Chris Peters wrote:
> 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 <news:comp.lang.c>, you
want <news:comp.lang.c++>.