Skip to content

Constructor Visibility - #6885

Merged
Mohamed Hegazy (mhegazy) merged 18 commits into
microsoft:masterfrom
AbubakerB:constructorAccessibility
Feb 17, 2016
Merged

Constructor Visibility#6885
Mohamed Hegazy (mhegazy) merged 18 commits into
microsoft:masterfrom
AbubakerB:constructorAccessibility

Conversation

@AbubakerB

Copy link
Copy Markdown
Contributor

Constructor Visibility

(This is a updated PR from #4174)

There wasn't any detailed proposal, so I'm just going to list what this PR implements.

1) Constructor Visibility

  1. A constructor can now have the private or protected keyword on its signature.
  2. All constructor overloads must be of the same visibility (i.e. all private, protected, or public)

2) Private Constructors

A class with a private constructor:

  1. Can only be instantiated within it's own class.
  2. Can only be extended within it's own class.

3) Protected Constructors

A class with a protected constructor:

  1. Can only be instantiated within it's own class.
  2. Can be extended.

4) Signature Assignability

  • A public, protected and private signature is assignable to a private signature.
  • A public and protected signature is assignable to a protected signature.
  • A public signature is assignable to public signature.

Loading
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants