What is Class ?
- A class is a user define data type.
- A class is a blueprint for creating objects (a particular data structure).
- Class is a collection of data member and member function .
- The user-defined objects are created using the class keyword.
Syntax :
class class_name:
Statements .......
Example :
>>> class abc:
print("in class abc")
in class abc
>>>
What is object ?
- An object is an instance of class.
- when class is define no memory is allocated but when object is created memory is allocated.
Example :
>>> class math:
def add(self):
return 3+3
>>> m = math()
>>> m.add()
6
>>>
Comments
Post a Comment