Thread: need help with destructor

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    7

    need help with destructor

    I have a class named PolyLine with the following data members:

    double *xArray;
    double *yArray;
    int length;

    I have a destructor:

    ~PolyLine()
    {
    cout << "I'm destroying you";
    delete [] xArray;
    delete [] yArray;
    }

    when I delete a PolyLine:

    delete p1;//where p1 is a pointer to a PolyLine

    The text "I'm destroying you" is printed but the object can still be printed. Could someone tell me what I am doing wrong ? Thanks
    Last edited by grimjb; 10-01-2001 at 08:14 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Destructor being called on SGI hash_map key
    By cunnus88 in forum C++ Programming
    Replies: 4
    Last Post: 02-11-2009, 12:05 AM
  2. exception in the destructor
    By coletek in forum C++ Programming
    Replies: 3
    Last Post: 01-12-2009, 12:01 PM
  3. Replies: 1
    Last Post: 06-10-2008, 08:38 PM
  4. Destructor inaccessible
    By renanmzmendes in forum C++ Programming
    Replies: 5
    Last Post: 02-19-2008, 11:07 AM
  5. destructor question
    By kocika73 in forum C++ Programming
    Replies: 3
    Last Post: 03-10-2006, 11:29 AM