This preview shows page 1. Sign up to view the full content.
Unformatted text preview: on
that data in the same class • Information hiding is a design principle that strives to shield client classes from the
internal workings of a class.
• Encapsulation facilitates, but does not
guarantee, information hiding.
• Smearing the two into one concept prevents
a clear understanding of either.
Page 9 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP public and private modifiers
• Let’s consider a class X.
• Let’s consider Y a client class of X.
• Y is a class that uses X. • Attributes (and methods) of X declared with the public modifier are accessible from instances of Y. • The public modifier does not guarantee the information
hiding. • Attributes (and methods) of X declared with the private modifier are not accessible from
instances of Y. • The private modifier guarantee the information hiding. Page 10 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Accessibility from Inside
(the Instance itself)
private - Accessible
- Inaccessible All members of an instance
are accessible from the
instance itself. Page 11 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Accessibility from
an Instance of another Class
View Full Document
This document was uploaded on 03/03/2014.
- Spring '14