Thread: Default Method

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    2

    Default Method

    Hi,

    I am new to C++, passionate about the perspective it offers but still find that the learning curve is somehow steep ;-)

    I am trying to put together a little String object, defining it as a type.

    I would like my object to return its content through a "default" method. That way I could console out the "content" (so to speak) of the String without having to explicitly call its Text (or Value whatever) method.

    Something like
    cout << myString << endl;

    thank you very much !

  2. #2
    ‡ †hë Ö†hÈr sîÐè ‡ Nor's Avatar
    Join Date
    Nov 2001
    Posts
    299
    http://faq.cprogramming.com/cgi-bin/...ring&match=all

    Try reading the tutorials this site offers.
    Try to help all less knowledgeable than yourself, within
    the limits provided by time, complexity and tolerance.
    - Nor

  3. #3
    The larch
    Join Date
    May 2006
    Posts
    3,573
    You need to overload operator << for std::ostream and String (and perhaps also >> for std::istream and std::getline).
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  4. #4
    Registered User
    Join Date
    Jul 2007
    Posts
    2
    Quote Originally Posted by anon View Post
    You need to overload operator << for std:stream and String (and perhaps also >> for std::istream and std::getline).
    I should have thought about it. Thanks a lot !!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Overriding a method in C
    By DavidDobson in forum C Programming
    Replies: 1
    Last Post: 07-05-2008, 07:51 AM
  2. Bisection Method function value at root incorrect
    By mr_glass in forum C Programming
    Replies: 3
    Last Post: 11-10-2005, 09:10 AM
  3. Open default browser and send an HTTP request (POST Method)
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 09-03-2005, 01:31 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