
CS 110 Notes Classes III 1
Copyright C. Tanner 2009
โข Class
o Standalone entity
o Object
o Application class
๎ Driver of program
๎ Contains main method
o Worker or support classes
๎ Reusable elements
๎ Model real world entities
o Decompose problem into series of classes
โข Class is made up of
o Data
๎ Data members
o Operations
๎ Act upon the data
๎ Member functions
o Encapsulate them into one object โ class
๎ Provide a mechanism to โhideโ data members from other classes
โข Isolates data member from unauthorized change
โข Private
๎ Provide operations to modify and return data members
o Class definition
Modifer(s) class ClassName modifer(s)
{
Data members/fields
Member methods
}
โข Data members/fields
o Constant declarations
o Variable declarations
โข Member methods
o Automatically have access to the data members and constants
o Direct access, scope
o Can use other class member methods
โข Modifiers
o Determine the accessibility of class members
o Private
๎ Can only be accessed by other class members
o Public
๎ Anyone/code can access it
โข Data member declares
o Visibility dataType identiferName [=value]
โข Member method declare
o Visibility method header