Lec 11 OOP
Lec 11 OOP
Copyright © 2012
Copyright
Pearson ©
Education,
2012 Pearson
Inc. Education, Inc.
Class Members
OOP Characteristics
Copyright © 2012
Copyright
Pearson ©
Education,
2012 Pearson
Inc. Education, Inc.
What Is Inheritance?
Copyright © 2012
Copyright
Pearson ©
Education,
2012 Pearson
Inc. Education, Inc.
Protected Members and
Class Access
• protected member access specification:
like private, but accessible by objects of
derived class.
Copyright © 2012
Copyright
Pearson ©
Education,
2012 Pearson
Inc. Education, Inc.
Constructors & Destructors in
Base and Derived Classes
• Derived classes can have their own constructors
and destructors.
Square::Square(int
side):Rectangle(side,side)
derived constructor base constructor
parameter parameters
Copyright © 2012
Copyright
Pearson ©
Education,
2012 Pearson
Inc. Education, Inc.
Class Hierarchies
• A base class can be derived from another
base class.
Copyright © 2012
Copyright
Pearson ©
Education,
2012 Pearson
Inc. Education, Inc.
Multiple Inheritance
• A derived class can have more than one base
class
• Each base class can have its own access
specification in derived class's definition:
class cube : public square,
public rectSolid;
class class
square rectSolid
class
cube