Course Web Pages

Related Links

Free eBooks


Classes

The videos below explain how to define classes with data members and member functions, how to instantiate objects, access data members, call member functions, define and use constructors, specify private and public access levels, define accessors and mutators, and how to define and use constant and static member functions. The examples are taken from Beginning C++ Through Game Programming, by Michael Dawson.

Simple Critter

 simple_critter.cpp


Constructor Critter

 constructor_critter.cpp


Private Critter

 private_critter.cpp


Private Critter with Header File

 private_critter_with_header.zip


Static Critter

 static_critter.cpp


Critter Caretaker

 critter_caretaker.cpp


Exercise

  1. Improve the Critter Caretaker program so that you can enter an unlisted menu choice that reveals the exact values of the critter's hunger and boredom levels.
  2. Change the Critter Caretaker program so that the critter is more expressive about its needs by hinting at how hungry and bored it is.