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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:18:15+00:00 2026-05-16T14:18:15+00:00

I have the following problem: //A.h class A { //… // this is the

  • 0

I have the following problem:

//A.h

class A
{
  //...
  // this is the important part, i have to call this in the proper way
  // in A::SetNewValue(), but i don't know how to do that
  protected:
    void SetValue(const int* i);
  //...

  public:
    // ??
    void SetNewValue(const int* p);
}

the cpp:

//A.cpp
//??
A::SetNewValue(const int* p)
{
  // ??
  this->SetValue(&p);    
}

and…

//...
// and later in another file...
//...
A a = new A();

int a_value = 4;
int* p;
p=&value;

// ??
a->SetNewValue(p);

The problem explained: class A is a built-in class in a framework. I have no way to modify protected A::SetValue() to public, and I can’t reach it from ‘outside’. So i’ve decided to write another function A::SetNewValue() to call A::SetValue, but I don’t know how to pass pointers and references in function parameters. I’ve always got erros like: can’t convert from * to &, const * to *, and so on…

How can i do this in a proper way? Is this even possible?

Thank you very much for your effort, and for your help.

Edit: Code above is a sample.. I’ve tried passing parameters in several ways

  • 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-16T14:18:16+00:00Added an answer on May 16, 2026 at 2:18 pm

    SetValue takes a pointer just like SetNewValue so you can pass the pointer value straight through:

    void A::SetNewValue(const int* p)
    {
        SetValue(p);    
    }
    

    I also fixed the missing void return type in your function definition.

    You should be able to call it with a pointer to int or const int because you can always add a const at the top level when passing pointer.:

    A a;
    
    int a_value = 4;
    
    a.SetNewValue(&a_value);
    

    I fixed your a variable to be just default constructed; I think that trying initialize a non-pointer a with a pointer to A (from new A) was probably a mistake.

    I changed -> to . as a is not a pointer.

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

Sidebar

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.