M7-GUIDE
M7-GUIDE
STUDY GUIDE
MODULE 7
SUBTOPIC 1: ABSTRACTION
Example:
class circle : public shape { ...
anybody can convert (assign) a circle* into a shape*
class circle : protected shape { ...
only members and friends of circle or its derived classes can convert (assign) a circle* into a
shape*
class circle : private shape { ... only members and friends of circle can convert (assign) a
circle* into a shape*
Access Specifiers/Modifiers
a) private
b) public
c) default (no keyword)
d) protected
PRIVATE
PROTECTED
Encapsulation and Inheritance
Visibility rules
Public and Private parts of an object declaration/definition
2 reasons to put things in the declaration
▪ so programmers can get at them
▪ so the compiler can understand them
▪ At the very least the compiler needs
▪ to know the size of an object, even though
▪ the programmer isn't allowed to get
▪ at many or most of the fields (members)
▪ that contribute to that size
EXAMPLE:
class circle : public shape { ...
anybody can convert (assign) a circle* into a shape*
Multiple Inheritance
Object-Oriented Programming
Ada 95
• tagged types
• single inheritance
• no constructors or destructors
• class-wide parameters:
• methods static by default
• can define a parameter or pointer that grabs the object-specific version
of all methods
• base class doesn't have to decide what will be virtual
• notion of child packages as an alternative to friends