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
    23,773
    Yes, it says that name() returns a const reference.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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, 04:53 PM
  2. beginner's question :D
    By kingliaho in forum C Programming
    Replies: 5
    Last Post: 10-17-2008, 05:20 PM
  3. beginner's question about C
    By Roberto Llovera in forum C Programming
    Replies: 5
    Last Post: 02-26-2004, 04:14 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 08:22 PM

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