Description of public, private, protected

Asked 2 years ago, Updated 2 years ago, 68 views

I saw the professor's PPT that distinguished the types of methods in the class diagram public - Access control to disclose one's attributes or actions to the outside world Private-Access control accessible only to inherited derived classes Access control that can only access the member functions of the protected-structure and cannot be accessed from the outside

It says so. But I wanted to distinguish between private and protected I tried googling, but I think the explanation between private and protected has changed... Is there anyone who is sure?

class oop

2022-09-22 18:13

1 Answers

It's not hard.

Private is literally accessed only within that class. You will not be exposed to the child class after inheritance.

protected is accessed from the same package and child class.


2022-09-22 18:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.