1 / 7

Understanding Function Fundamentals in CIS 601: Key Concepts for Safe Computing

This resource covers crucial concepts in function implementation for CIS 601, including the importance of the 'skeleton' in maintaining type-safe computing. It discusses where and when to apply const, member functions, and how to handle class friendships to control access to private data. You'll learn about function overloading with different signatures and the necessity of using common sense when naming overloaded functions. This guide serves as a foundation for building robust and secure code practices.

helen
Télécharger la présentation

Understanding Function Fundamentals in CIS 601: Key Concepts for Safe Computing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 CIS 601 Fall 02

  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 CIS 601 Fall 02

  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); CIS 601 Fall 02

  5. this • Pointer (address) of current object • Only permitted in member function • obj & Obj::echo(Obj anObj){ return *this;} • * dereferences this • & and * are inverses of each other CIS 601 Fall 02

  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.) CIS 601 Fall 02

  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 CIS 601 Fall 02

More Related