Introduction to Classes and Objects
Introduction to Classes and Objects
Objects
Course General Information
Evaluation
Criteria
Methods of Assessment will be made based on the midterm exam (30%), final exam (30%), practical
Evaluation Assignment (10%), Quizzes (15%), Class Attendance (5%) and Project(10%)
Four Basic Properties of Object Oriented
Programming
Classes in C++
• A class definition begins with the keyword
class.
• The body of the class is contained within a set
of braces, { } ; (notice the semi-colon).
3. They are usually grouped under two sections , namely private and
public to denote which of the members are private and which of them
are public.
Both of the objects Box1 and Box2 will have their own
copy of data members.
Private and Public Visibility Labels
Function Body
}
A C++ Program with Class
Private Member Function
A private member function can only be called by another
function that is a member of its class. Even an object cannot
invoke a private function using dot operator.
set Functions and get Functions
- width : double
- length : double
UML Parameter Type Notation
• To indicate the data type of a function’s
parameter variable, place a colon followed by
the name of the data type after the name of
the variable.
+setWidth(w : double)
UML Function Return Type Notation
25
The Rectangle Class