function that returns a constant reference

This is a discussion on function that returns a constant reference within the C++ Programming forums, part of the General Programming Boards category; Code: std::string const & user::nickname() const { return m_data->nickname; } Here what is the meaning of & used? THanks....

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

    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をこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,538
    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
    24
    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, 02:25 PM
  2. Assigning an object variable to a constant reference
    By Canadian0469 in forum C++ Programming
    Replies: 18
    Last Post: 11-10-2008, 09:48 AM
  3. Replies: 9
    Last Post: 01-29-2006, 05: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

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