New/Delete operators

Discussion in 'C++' started by Duece_68, Sep 30, 2010.

  1. Duece_68

    Duece_68 New Member

    Joined:
    Sep 30, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi I was just wondering if I create a pointer using the new operator and then I call the new operator on that same pointer later on would that overwrite the existing pointer so that I do not waste memory on the heap or do I have to delete it then use the new operator again.

    EG:

    Code:
     
    ClassA* objA = new ClassA();
    .
    .
    objA = new ClassA();
     
    OR

    Code:
     
    ClassA* objA = new ClassA();
    .
    .
    delete objA;
    objA = new ClassA();
     

    Thank You in advance
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice