Thread: string class

  1. #1
    Registered User
    Join Date
    Mar 2019
    Posts
    51

    string class

    string name;
    cout<< name << endl;

    Will the above statement display an object?

    I was told that object. (class data member)
    But here we are passing direct to a string object. And It works too. How?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Because string comes with an operator overload for << to do what you think it ought to.
    operator<< (string) - C++ Reference
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String class
    By dpp in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2009, 12:29 AM
  2. String Class
    By BKurosawa in forum C++ Programming
    Replies: 117
    Last Post: 08-09-2007, 01:02 AM
  3. What is the best string class to use?
    By Eber Kain in forum C++ Programming
    Replies: 3
    Last Post: 09-12-2003, 12:39 PM
  4. string class
    By jjg in forum C++ Programming
    Replies: 2
    Last Post: 09-12-2002, 07:58 PM
  5. String Class
    By JBravo in forum C++ Programming
    Replies: 8
    Last Post: 02-24-2002, 06:38 AM

Tags for this Thread