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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:17:10+00:00 2026-05-16T07:17:10+00:00

Do the methods of a member variable have access to other private member variables

  • 0

Do the methods of a member variable have access to other private member variables within the same class? I have in mind a functor member variable.

Can a pointer to a private member variable be dereferenced and assigned to, outside of the class? What about in the method of another member variable?

Maybe something like

class A
{
 someClass a,b;

 A(){a(&b);}
}
  • 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-16T07:17:11+00:00Added an answer on May 16, 2026 at 7:17 am

    Whenever you are calling the method of a member variable, unless its type is the class being defined, you won’t have access to private member variables.

    If you give access (somehow) to a pointer to a member variable, without precising that it is “const”, yes, it can be dereferenced and assigned to. The same assertion is still true for the methods of other member variables.

    AFTER QUESTION HAS BEEN EDITED :
    In your example, you are calling a method (through member variable “a”), providing a pointer to private member variable “b”. You are accessing these two private member variables in A, which is perfectly correct c++.

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

Sidebar

Related Questions

I notice that if you have a private member in a class, you can
Is it more efficient for a class to access member variables or local variables?
What do you do with classes that have no member data, only methods? Do
I'm generating compiled getter methods at runtime for a given member. Right now, my
Classes that use other classes (as members, or as arguments to methods) need instances
Should methods in a Java interface be declared with or without the public access
Certain methods in Java will block until they can do something, like ServerSocket.accept() and
Several questions about accessor methods in C++ have been asked on SO, but none
It seems that unsigned integers would be useful for method parameters and class members
What methods are there for automatically getting a stack trace on Unix systems? 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.