Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6761479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:11:45+00:00 2026-05-26T14:11:45+00:00

Sorry for turning to here for such a basic question, but can someone just

  • 0

Sorry for turning to here for such a basic question, but can someone just quickly clear this up for me? I’ll then delete the thread so as not to cause noob clutter.

In the following example from the C++ Primer Plus text, doesn’t the & operator in the function declaration designate that the function returns a pointer to a Stock object? Why then does the function proceed to return the s and this objects by value instead?

“…What you want to return, however, is not this, because this is the address of the object. You want to return the object itself, and that is symbolized by *this. (Recall that applying the dereferencing operator * to a pointer yields the value to which the pointer points.) Now you can complete the method definition by using *this as an alias for the invoking object.”

const Stock & Stock::topval(const Stock & s) const {

if (s.total_val > total_val)

   return s;           // argument object

else

   return *this;       // invoking object
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:11:46+00:00Added an answer on May 26, 2026 at 2:11 pm

    Yeah, that’s confusing. C++ massively overloads every symbol, because there just aren’t enough symbols on the keyboard.

    The ampersand & is used for two different meanings which are conceptually similar, but are actually completely different language features.

    Meaning 1: Reference type declaration. Append an ampersand to type A which means a-reference-to-type-A. Example:

    Stock x;
    Stock& s = x; // now s is a reference to x
    

    Meaning 2: Address-of operator. A unary operator that returns a pointer to its argument. Example:

    Stock x;
    Stock* s = &x; // now s a pointer to x
    

    Reminder: References and pointers are exactly the same thing, except they have different syntax, and references can never be null, and you can’t have a reference to a reference.

    Don’t delete this thread, we love n00bs. I’m a n00b myself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for this basic question but my searches on this are not turning up
Sorry for this newbie question but I cannot figure how I can do this..
Sorry I can't think of a good title for this but here' my situation:
Sorry for this not being a real question, but Sometime back i remember seeing
Sorry if this sounds like a really stupid question, but I need to make
Sorry if this sounds like a newbie question, but the other day a Java
sorry for being dumb here, but I failed to see why these tools can
Sorry for a long question but here goes. I am trying to modify the
Sorry, still reasonably new to Javascript here, so hope this question isn't too embarrassingly
Sorry for the basic question - I'm a .NET developer and don't have much

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.