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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:37:47+00:00 2026-05-16T23:37:47+00:00

struct A { protected: int y; public: int z; }; struct F : A

  • 0
struct A {
protected:
  int y;
public:
  int z;
};

struct F : A {
public:
  using A::y;
private:
  using A::z;
};

int main() {
  F obj_F;
  obj_F.y = 9;
  obj_F.z = 10;
}

Source: http://publib.boulder.ibm.com/infocenter/comphelp/v7v91/index.jsp?topic=/com.ibm.vacpp7a.doc/language/ref/clrc14cplr135.htm

In the above code obj_F.z = 10; – is allowed.
Explanation: The access of member z is still public. The private using declaration using A::z has no effect on the access of z.

Can someone tell me, if z, which is declared as private, is accessible outside, then what is the meaning of that private? What does it do?

Thanks

-Saiyasodharan

  • 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-16T23:37:48+00:00Added an answer on May 16, 2026 at 11:37 pm

    The code is valid according to the Standard – see this Standard rule, which I did not have in mind when I answered before

    A member m is accessible when named in class N if

    • […], or
    • there exists a base class B of N that is accessible at the point of reference, and m is accessible when
      named in class B.

    This entirely applies to your code, and thus the access is valid… It appears the main purpose of this rule is for allowing friend declarations of the base to apply to inherited members, but it also applies to this case.


    (Disregard the parts of this that say the code is invalid – It’s valid as explained above. This part is an old version of my answer, kept here to serve as background information)

    No, this code is invalid. That’s why the equivalent “access-declarations” are called that way (these are deprecated though)

    struct F : A {
    public:
      A::y;
    private:
      A::z;
    };
    

    These are called “access-declarations” precisely because they can change the access… In your example the naming class is F and z as a member of F is private because the using-declaration did change the access level of the name z.

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

Sidebar

Related Questions

I have a data structure Person struct Person { protected: string name; int age;
struct Div { int i; int j; }; class A { public: A(); Div&
I have the Parent Class : class clsTestParent { protected int x; public void
ProjectileManager inherits from EntityManager, which has this as a protected member: struct EntityDeallocator{ void
struct pointsto_val_def { unsigned int lhs; bitmap rhs; struct pointsto_val_def *next; }; typedef struct
struct Foo { int data; Foo() = default; Foo(const Foo& arg) = default; };
struct { char a; int b; } x; Why would one define a struct
struct SomeStruct { int a; int b; }; SomeStruct someFn( int init ) {
This is what I would like to do using templates: struct op1 { virtual
I have a class defined like this: public class StateMachineMetadata<T> where T: struct {

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.