Class 2: Functions - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

Class 2: Functions

Description:

When: always (even when not required) Where: at top of .cpp file ... and * are inverses of each other. CIS 601 Fall 02. friend ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 8
Provided by: barry59
Category:

less

Transcript and Presenter's Notes

Title: Class 2: Functions


1
Class 2 Functions
2
Next week
  • For Sept 27
  • Page 102, 3.10.2 (1) Playing cards
  • Page 103, 3.10.3(1) Employee Class

3
Function prototype
  • What the skeleton
  • Why (type) safe computing
  • When always (even when not required)
  • Where at top of .cpp file
  • Note .h (header) file takes care of this for a
    class

4
const
  • Only with
  • What would void func(const int aVar) mean?
  • A function may be const
  • Never return a non-const reference to private
    dataprivData func(int aVar)

5
this
  • Pointer (address) of current object
  • Only permitted in member function
  • obj Objecho(Obj anObj) return this
  • dereferences this
  • and are inverses of each other

6
friend
  • friend classes get access to private information
  • You get to decide who your friends are
  • class ClassA friend ClassB
  • Friendship is not transitive. (A friend of a
    friend is not a friend.)

7
Overloading
  • Different functions, same name
  • Must have different signatures (Note Type
    difference is not enough)
  • Use common sense overloaded names should do
    similar things!
  • Often overload constructors
Write a Comment
User Comments (0)
About PowerShow.com