a question about class and string

This is a discussion on a question about class and string within the C++ Programming forums, part of the General Programming Boards category; string3=string1.concat(string2); how can I write a "concat" function which does this work with using class....

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    34

    a question about class and string

    string3=string1.concat(string2);

    how can I write a "concat" function which does this work with using class.

  2. #2
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    Are you writing you own string class?

    If not, the standard library has all this ready for you. You simply do the following:

    string3 = string1 + string2;

    or, to add string2 to string1:

    string1 += string2;

    If you look at the basic_string class method list, you will see a whole list of operaters.

  3. #3
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    If you are writting your own class, declare a function concat that takes a string object as argument, and do the concatenation yourself( I assume that you are storing the string as char *), using pointers.
    none...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 05:30 PM
  2. Replies: 8
    Last Post: 04-25-2008, 03:45 PM
  3. Inheritance Hierarchy for a Package class
    By twickre in forum C++ Programming
    Replies: 7
    Last Post: 12-08-2007, 04:13 PM
  4. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 07:49 PM

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