Skip to content

private and protected access #4575

@josh11b

Description

@josh11b

Summary of issue:

What precisely are the rules that determine what has access to members with private or protected access modifiers?

Here are some questions that I don't think are addressed by the current design:

  • Can methods in an adapter of C access protected members of C?
  • Is access enforced only on name lookup and resolution, or is it affected by member binding? (For example, does access to a protected member of a base class require it be applied to an object or value of the current derived class?)
  • Can a function on C(T) access private & protected members of C(U)?
  • If Derived(T) extends Base(T), can Derived(T) access protected members of Base(U)?

Context:

Classes: Access control documents the currently accepted design for access control modifiers. It documents the basics such as:

  • private means only accessible to members of the class and any friends.
  • Protected members may only be accessed by members of this class, members of derived classes, and any friends.

Metadata

Metadata

Assignees

No one assigned

    Labels

    leads questionA question for the leads team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions