Thread: deleting an object?

  1. #1
    Unregistered
    Guest

    Question deleting an object?

    hi all,
    can someone tell me the best way to delete an object?

    i have a car database and need to delete a car which has:


    reg no.
    make
    model
    price


    thanks to all who respond.
    jim

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    479
    do you need to delete an object?

    maybe u mean a constructor!?

    if so use a"~"

    else u just write delete and then the stuff u want to delete!

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    142
    yeah i mean, are there any other way than these two?

    delete object;
    delete [] object;?

    don't forget to set it to NULL afterwards though,

  4. #4
    Registered User Aran's Avatar
    Join Date
    Aug 2001
    Posts
    1,301
    you can't call a destructor within your program, just so you know.

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    you could dynamically allocate memory for the class then delete it. create a destructor.

  6. #6
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    Originally posted by Aran Elus
    you can't call a destructor within your program, just so you know.
    This is true. Use a normal function to destroy the object, which can then be called by the destructor instead.

  7. #7
    Registered User JoshG's Avatar
    Join Date
    Mar 2002
    Posts
    326
    You say you have a database of cars, and you want to delete one. Do you mean delete an object or delete a record from the database?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deleting object after list removal (C++ visual studio)
    By RancidWannaRiot in forum Windows Programming
    Replies: 2
    Last Post: 10-20-2005, 06:06 PM
  2. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 04:33 PM
  3. A question about constructors...
    By Wolve in forum C++ Programming
    Replies: 9
    Last Post: 05-04-2005, 04:24 PM
  4. deleting dynamic object problem
    By eth0 in forum C++ Programming
    Replies: 17
    Last Post: 05-19-2004, 01:17 PM
  5. Array of Pointers + Deleting An Object = Problems
    By Nereus in forum C++ Programming
    Replies: 3
    Last Post: 03-04-2004, 12:16 PM