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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:53:53+00:00 2026-06-09T05:53:53+00:00

Suppose I have two classes: class A { int x; int y; }; class

  • 0

Suppose I have two classes:

class A
{
    int x;
    int y;
};


class B
{
    int z;
    A ref;
};

Suppose I also have a function that accepts a pointer-to-member integer of B, like so:

void doSomethingToB(B* object, int B::* val)
{
    if(val)
    {
        std::cout << object.*val;
    }
}

Would there be a way that I could point to a member of ref inside B?

Like, int B::* ptr = &(B::ref.x) or something similar?

  • 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-09T05:53:54+00:00Added an answer on June 9, 2026 at 5:53 am

    This question gets asked from time to time

    Is Pointer-to- " inner struct" member forbidden?

    Basically, this can be described is a rather obvious initial oversight in the design of C++ language, which has has been ignored ever since due to the fact that the language develops in higher-level directions. Pointers of pointer-to-data member type are probably considered too low-level to be given enough attention. I wouldn’t be surprised to discover one day that such pointers are deprecated instead of being developed further.

    To repeat my statement from the linked answer, the low-level support is already there in every C++ compiler (since the low-level mechanism is the same regardless how deeply the member is “nested” – it is simply the offset of the member on the containing object), but the corresponding initialization syntax is missing.

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

Sidebar

Related Questions

Suppose we have two classes: class Base { private: int x; public: void f();
suppose you have two (or more) classes with private member vectors: class A {
Suppose that I have two classes, first a class without any properties, fields or
Suppose I have two classes: public class Student { public int Id {get; set;}
Suppose I have these two classes class base_size { public: int size() { return
Suppose I have two classes like so: class Parent def say I am a
Supposed I have two classes like this: public class Parent { public string Id
Suppose I have two classes that both contain a static variable, XmlTag. The second
Suppose we have following two classes: class Temp{ public: char a; char b; };
Suppose I have two classes defined the following way: public class A { 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.