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

  • Home
  • SEARCH
  • 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 8575081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:36:58+00:00 2026-06-11T19:36:58+00:00

In the code below I would like to know what does the operator* overloadind

  • 0

In the code below I would like to know what does the operator* overloadind do here.

// struct pointer to Shape
struct PtrToShape
{
Shape *ptr;

bool operator < (const PTRToShape & rhs) const
{ return *ptr < *rhs.ptr; }

const Shape & operator*() const
{ return *ptr; }

};

What will it overload? Will it overload the * operator for the struct or for the shape objects? Is this overloading used in:

return *ptr < *rhs.ptr

And in the line I previously mentioned the * (overloaded or not) refers to what? to rhs or to rhs.ptr ?

Thank you.

  • 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-06-11T19:36:59+00:00Added an answer on June 11, 2026 at 7:36 pm
    const Shape & operator*() const
    { return *ptr; }
    

    This returns a reference dereferenced Shape object, the one called ptr, which is a member of your struct.

    That overload will overload this *operator for your PtrToShape struct.

    Also, no, it’s not used in return *ptr < *rhs.ptr

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

Sidebar

Related Questions

I would like to know memory leak in the below mentioned code. Does JavaScript
I would like to implement a parallel version of the code below using threads
For the code below, I would like to append echo $_SERVER['QUERY_STRING']; to the end
guys, I would like to you evaluate next code below. As you see, I
Below is the code from a plugin I use for sitemaps. I would like
I have the below question, and would like to know if I have interpreted
I would like to determine if the below code would allow the CPU to
I understand that the code below would result segmentation fault because at the cstr
I am trying to implement does_key_exist, I thought the code below would do it.
In the code below I would expect t2: [{value:.....}, {}, {}] but instead I

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.