Beginner's Question

This is a discussion on Beginner's Question within the C++ Programming forums, part of the General Programming Boards category; I was just reading through C++ Annotations and I am at the point where the author is starting with classes. ...

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    2

    Beginner's Question

    I was just reading through C++ Annotations and I am at the point where the author is starting with classes. I noticed that the author declares one of the member functions

    Code:
    std::string const &name() const;
    and I was wondering what would be the ultimate difference if

    Code:
    std::string const name() const;
    was used instead. The function just returns the name but I am curious as to what this would mean with a more complex function.

    Thanks in advance,

    M

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    2
    Oh, is the & symbol referring to the return value? This might just be a reading issue for me but I just wanted to make sure.

    M

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,308
    Yes, it says that name() returns a const reference.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    15
    Thank you much.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner's Question on QT
    By unix7777 in forum C++ Programming
    Replies: 1
    Last Post: 11-30-2008, 05:53 PM
  2. beginner's question :D
    By kingliaho in forum C Programming
    Replies: 5
    Last Post: 10-17-2008, 06:20 PM
  3. beginner's question about C
    By Roberto Llovera in forum C Programming
    Replies: 5
    Last Post: 02-26-2004, 05:14 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 10:47 PM
  5. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM

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