user-defined String class

This is a discussion on user-defined String class within the C++ Programming forums, part of the General Programming Boards category; Hi all I am having trouble writing a function in my string class that i have defined myself. The definition ...

  1. #1
    Unregistered
    Guest

    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
    Posts
    552
    strcpy(str+starting_pos, str+ending_pos+1);

  3. #3
    Unregistered
    Guest

    strcpy

    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];
    ?
    -thanks

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, 04: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, 09:33 PM
  5. Replies: 3
    Last Post: 12-03-2001, 12:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21