Compilation error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Peters

    Compilation error

    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.


  • Antoninus Twink

    #2
    Re: Compilation error

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

    Comment

    • Sjouke Burry

      #3
      Re: Compilation error

      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.

      Comment

      • CBFalconer

        #4
        Re: Compilation error

        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 .att.net>
        Try the download section.

        Comment

        • Martin Ambuhl

          #5
          Re: Compilation error

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

          Comment

          Working...