Thread: how to delete string variables

  1. #1
    Unregistered
    Guest

    Question how to delete string variables

    I've tried using delete[] but my MSVC6 compiler says it's not a pointer. Is there another solution to delete string variables (let's say using string.h).

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    17
    You only need to use delete if you have defined your string var. as a dynamic pointer.

    eg.

    Code:
    string *myStringOne;
    string *myStringTwo;
    
    myStringOne = new string;
    myStringTwo = new string[999];
    
    // deleting at a  later stage
    
    delete myStringOne;
    delete [] myStringTwo;
    by the sounds of it you haven't, so remove the delete code.
    -----------------------------------------------
    everready

    To code, or not to code, that is the question.

    Well the answer is 'TO CODE' of cause

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  2. Inheritance Hierarchy for a Package class
    By twickre in forum C++ Programming
    Replies: 7
    Last Post: 12-08-2007, 04:13 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM
  5. Problem need help
    By Srpurdy in forum C++ Programming
    Replies: 1
    Last Post: 07-24-2002, 12:45 PM