Thread: clear method

  1. #1
    Registered User
    Join Date
    May 2003

    clear method

    I have a Class called CSIString, but in that class there is no method to clear a string. I want to write my own method, and I'm thinking I should just be able to do something like:

    str = "";

    but that doesn't work. Any of you C++ folk out there have my answer??? Thanks in advance

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    It depends on the internal structure of the class. Since a properly designed class should hide that from you, it depends on what operations the interface allows you to perform. Can you give us some more information? Here's a short list of info that would help us:

    1) The class declaration
    2) Is it your class?
    3) Can you make any changes?
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Apr 2003
    1)Since you don't give any information about the data members of your class or the constructors, how would you expect anybody to help you?

    2)Why would you ever need to "clear" a string?

    3)If you can construct a string from your class that is "aaaaa", then you can construct a string that is all spaces.

    3)If you can't fill a string with blanks or \0's you need to study some beginning C++ tutorials on arrays.
    Last edited by 7stud; 05-21-2003 at 01:43 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stuck on display method
    By shintaro in forum C++ Programming
    Replies: 2
    Last Post: 02-01-2009, 05:17 PM
  2. Best communication method to thousand childs?
    By Ironic in forum C Programming
    Replies: 8
    Last Post: 11-08-2008, 12:30 AM
  3. About clear(). Please help!
    By Antigloss in forum C++ Programming
    Replies: 12
    Last Post: 07-14-2005, 04:02 AM
  4. How to pass non-static method to signal() function?
    By registering in forum C++ Programming
    Replies: 3
    Last Post: 11-06-2003, 04:33 PM
  5. Replies: 3
    Last Post: 12-03-2001, 01:45 PM