Thread: user-defined String class

  1. #1

    user-defined String class

    Hi all
    I am having trouble writing a function in my string class that i have defined myself.
    The definition of the method should be this:
    my_string &erase(int starting_pos = 0, int ending_pos = size() );
    that should erase the characters from the string starting at start_pos through the position ending_pos. returns the resultant string for cascading.

    -thanks for help

  2. #2
    Registered User
    Join Date
    Jan 2002
    strcpy(str+starting_pos, str+ending_pos+1);

  3. #3


    I have used this function, but it is not suffices the requirements. I have to::
    1) copy the starting part to the new string.
    2) copy the ending part to the new string.
    3) delete the old string array
    4) assign the new array
    5) return the reference

    Also, how do you dynamically allocate a SIZE into an array of char, if you don't want to say ::
    char array[256];

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. RicBot
    By John_ in forum C++ Programming
    Replies: 8
    Last Post: 06-13-2006, 06:52 PM
  4. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  5. Replies: 3
    Last Post: 12-03-2001, 01:45 PM