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 636359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:30:23+00:00 2026-05-13T20:30:23+00:00

I have a class which looks approximately like this: class MeshClass { public: Anchor

  • 0

I have a class which looks approximately like this:

class MeshClass
{
public:
    Anchor getAnchorPoint(x, y)
    {
      return Anchor( this, x, y );
    }
private:
    points[x*y];
}

I want to make another class which represents an “Anchor” point which can get access to the Mesh and modify the point, like this:

class Anchor
{
public:
    Anchor(&MeshClass, x, y)
    moveAnchor(x, y);
}

The problem is when I try to make the Anchor in the MeshClass::getAnchorPoint method, something like return Anchor(this, x, y) but because this is const I can’t. As a workaround until I get this figured out I have Anchor accepting a reference to the point and moveAnchor moves the point directly.

Edit: The problem was most likely something dumb I was doing with trying to use a Reference. I changed to using a pointer like I normally would and I can pass in this with no complaints from the compiler. I’m almost certain I was getting an error related to this being const, but I can’t recreate it so I must just be out of my mind.

  • 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-13T20:30:24+00:00Added an answer on May 13, 2026 at 8:30 pm

    In C++, this is a pointer, not a reference. You could do something like this:

    class Anchor; //forward declaration
    
    class MeshClass
    {
    public:
        Anchor getAnchorPoint(int x, int y)
        {
            return Anchor(*this, x, y );
        }
    private:
        int points[WIDTH*HEIGHT];
    }
    
    class Anchor
    {
    public:
        Anchor(MeshClass &mc, int x, int y);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class which looks something like this: public class Test { private
Let's say I have a class which looks like this : public class MyClass
Good afternoon all, I have a class which looks like this: public class Grapheme
I have a class which looks like this: public class Field { public string
i have a class which looks like this public class Process_Items { String Process_Name;
I have a class which looks like this: public class NumericalRange:IEquatable<NumericalRange> { public double
I have a base class which looks something like this: class Base { public:
I have a class user which looks like this: public class User { public
I have a class Foo which looks like this class Foo { public: void
I have a class which looks something like this: class MyClass { public: //

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.