Defining a Class

Defining a Class

 Defining a class


Class is like a blueprint or a prototype that is used to create objects, Class is also a way to define your own data type Class is also a way of binding state and behaviour together of object We define classes by using the class keyword. The following statements ere defining a class called Person:

 

Creating object of class


Object is an instance of a class. The process of creating object of a class is known as instantiation. The following statements shew hew to create object of a class

 

Program for demonstration of class and object

Instance Members


A variable that is defined Inside a method and to which memory is allocated inside object of a class is called instance variable.

Every  object maintains a separate copy of its instance variables, if one object makes any change in its instance variable it will no: affect any other object’s Instance variables instance methods are the functions that are defined inside the class body and called through object reference are called instance methods. Instance methods are used to perform operation on instance variables of the class Collectively Instance variables and Instance methods are called instance members

Program for demonstration of instance members

Leave a Reply

Your email address will not be published. Required fields are marked *