Results can only be achieved if you have the focused direction and crystal clear knowledge. To achieve this, you need a mentor. We will help you out by connecting with an expert mentor in the field.Learn More
1 min 57 sec read
What is a class? Why is it being used in Object-oriented programming languages? What is actually Object-oriented programming?
Do you play games? Yes, a game like Super Mario, Pacman, breakout game, snake game, etc. These different types of games are the part of one big blueprint named as "GAME" :). So there is something which creates a blueprint of various types of games and keeps them together in a player like video games device (eg, Play Station, etc).
As I explained in above example, Class is just a blueprint which contains stuff like properties, variables, member functions and all. A class definition starts with class keyword followed by class name.
Objects can be anything. An object is just an instance of the class which holds the data variables declared in class and the functions work on these class objects.
class SampleClass: def function(self): print("Sample function inside a class.") classReference = SampleClass() classReference.function()
self parameter is a reference to the class itself and is used to access variables that belong to the class. classReference is the object of SampleClass() and you can access the functions or variables of the class using . dot operator.
Easy to use online data structure compiler where you can execute the programs in your favourite programming language.
(C, C++, Python)