They may represent a person, a place, a bank account that the program has to handle.
An instance of a class is called object.
We can create any number of objects related to the class. Each object contains data and code to manipulate
data. The following fig. shows the two ways to represent objects.
The problem is divided into number of entities called objects.
The data inside the objects are called attributes and related functions are called operations.
Objects – monitor, keyboard and CPU
Object = Data + Methods
NEED FOR OBJECTS:
Modularity - large software projects can be split up in smaller pieces.
Reusability - New software components can be written or developed from existing ones
Everything in the world is an object
A flower, a tree, an animal
A student, a professor
A desk, a chair, a classroom, a building
A university, a city, a country
The world, the universe
A subject such as CS, IS, Math, History, …
Class is template for an object. It is a collection of objects with same type of data and functions. We can
create any number of objects related to the class. Data items in a class are called data members. The function with in
a class is called member functions. (User defined class)
class name – fruit