Can anyone explain class method i totally confused in this topic please help. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can anyone explain class method i totally confused in this topic please help.

Need explanation on class

24th Apr 2020, 9:53 AM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
2 Answers
+ 1
Class has features and methods. The features are variables and the methods are functions that you add to the class. If you create a class for OOP that's the base. But if you use main method so it's the class which might use the objects and not create them or just do some other things of OOP.
24th Apr 2020, 10:15 AM
Eliya Ben Baruch
Eliya Ben Baruch - avatar
0
Classes are blueprint of objects... Instance is an object created based on the blueprint. Class define properties (attributes) and methods (functions) related to the instances object or not directly related (but usualy logicaly related). ie: we could create an Engine class, with properties such as type (heat, electric...)... and methods such as start, stop... (instance properties and method). We could also create class properties and methods (wich doesn't require an instance object to be used), such as count of Engine class instances created (class property) and/or a function to access this counter (class method) wich both applied to the family rather than a specific instance. We create any instances of Engine: heatEngine = Engine::construct(type='heat',...) electricEngine = Engine::construct(type='electric',...) ... and we use them: heatEngine::start() heatEngine::stop() ... and we could use a class method (or property): engines = Engine::count() (pseudo-code because you didn't specify any language)
25th Apr 2020, 12:15 AM
visph
visph - avatar