Thread: function that returns a constant reference

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    27

    function that returns a constant reference

    Code:
    std::string const & user::nickname() const
    {
       return m_data->nickname;
    }
    Here what is the meaning of & used? THanks.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Like the title says, it means a (constant) reference.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    27
    THX elysia

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pass by constant reference
    By Canadian0469 in forum C++ Programming
    Replies: 4
    Last Post: 11-15-2008, 03:25 PM
  2. Assigning an object variable to a constant reference
    By Canadian0469 in forum C++ Programming
    Replies: 18
    Last Post: 11-10-2008, 10:48 AM
  3. Replies: 9
    Last Post: 01-29-2006, 06:57 PM
  4. Replies: 10
    Last Post: 06-05-2004, 07:40 PM
  5. function returns int *
    By aripata in forum C Programming
    Replies: 1
    Last Post: 09-06-2001, 07:27 AM