And Even More and More C++ Fundamentals of Computer Science Outline - - PowerPoint PPT Presentation

and even more and more c
SMART_READER_LITE
LIVE PREVIEW

And Even More and More C++ Fundamentals of Computer Science Outline - - PowerPoint PPT Presentation

And Even More and More C++ Fundamentals of Computer Science Outline C++ Classes Friendship Inheritance Multiple Inheritance Polymorphism Virtual Members Abstract Base Classes File Input/Output Friendship Friend


slide-1
SLIDE 1

And Even More and More C++

Fundamentals of Computer Science

slide-2
SLIDE 2

Outline

 C++ Classes

 Friendship  Inheritance  Multiple Inheritance  Polymorphism  Virtual Members  Abstract Base Classes

 File Input/Output

slide-3
SLIDE 3

Friendship

 Friend functions

 A non-member function in a class marked as “friend” makes it

so that other instantiated objects of the same type can access each other’s information

slide-4
SLIDE 4

Friend Function Example

slide-5
SLIDE 5

More Friendship

 Friend Classes

 A friend of a class can access protected and private items

within that class

slide-6
SLIDE 6

Friend Class Example

slide-7
SLIDE 7

Inheritance

 Base class is the parent class  Derived classes are the children

 Children inherit the members of its parent  Children can also add their own members

slide-8
SLIDE 8

Inheritance Example

slide-9
SLIDE 9

Access Permissions

 External access permission to class data  Inherited members inherit access permissions dependent

  • n how they are declared

 Public – same access permissions (default for struct inheritance)  Protected – public and protected members inherited as protected  Private – all inherited members are private(default for class

inheritance)

slide-10
SLIDE 10

Inheritance

 What gets inherited?

 A publicly derived class inherits everything except:  constructors and destructor  assignment (operator=)  friends  private members

 this means that private variables are not inherited  need to provide getters and setters

 Even though not inherited, constructors and destructor are

automatically called by the child class

slide-11
SLIDE 11

Inheritance Example

slide-12
SLIDE 12

Multiple Inheritance

 Could do this in Python

 Not so in all languages

 Done by specifying more than one base class

separated by commas

slide-13
SLIDE 13

Multiple Inheritance Example

slide-14
SLIDE 14

Summary

 C++ Classes

 Friendship  Inheritance  Multiple Inheritance  Polymorphism  Virtual Members  Abstract Base Classes

 File Input/Output