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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:11:15+00:00 2026-05-23T00:11:15+00:00

I am having trouble getting my pointers to work correctly. In my main file

  • 0

I am having trouble getting my pointers to work correctly. In my main file I declare

Analysis2 analysis = Analysis2();
MaxResults maxresults = MaxResults( analysis);

Now in my MaxResults class, I want to point to analysis so that if any of its variables change I still get the right value. Right now I declare the constructor in the MaxResults header as

MaxResults(Analysis2 analysis);
Analysis2 * analysis2;

And in the MaxResults class

MaxResults(Analysis2 analysis)
{
    analysis2 = analysis;
}

When I try to access things from analysis that changed, analysis2 doesn’t seem to be keeping up. How do I fix this, and is there an easy way to remember pointers and referencing and dereferencing in the future?

  • 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-23T00:11:15+00:00Added an answer on May 23, 2026 at 12:11 am

    If you want MaxResults to keep a pointer to an Analysis2 object, you should do it like this:

    class MaxResults {
    
     public:
         MaxResults(Analysis* an) : analysis(an) {}
    
     private:
         Analysis* analysis;
    };
    

    and construct it like this:

    Analysis2 analysis = Analysis2();
    MaxResults maxresults = MaxResults( &analysis);
    

    Note the use of the address-of operator (&) to capture the address of analysis and pass it as pointer to the MaxResults constructor, which saves the pointer in a member (using an initialization list, which is more or less equivalent to doing analysis = an in the constructor’s body, just in case the : syntax is new to you).

    For further reading, have a look at references (once your got a better understanding of pointers, of course). In this case, references would probably be preferred.

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

Sidebar

Related Questions

I'm having trouble getting a rotary encoder to work properly with AVR micro controllers.
I'm having trouble getting the following to work in SQL Server 2k, but it
I'm having trouble getting in touch with SQL Server Managemen Studio 2008! I want
I'm having some trouble getting log4net to work from ASP.NET 3.5. This is the
I'm having trouble getting jQuery to load inside a file that has been imported
So I'm having trouble getting even a simple Makefile to work. Heres what I
i am having trouble getting this to work, can any one spot the issue?
I'm having trouble getting rmagick to work on windows. Does anyone know how to
I've been having trouble getting my ASP.NET application to automatically log users into the
I'm having trouble getting the right number of elements in the ArrayList alt in

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.