Object Oriented Programming | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Object Oriented Programming

Hi, can you explain these keywords: Class Objects What's the difference between these two?!

7th Feb 2019, 6:32 PM
Amir H.
Amir H. - avatar
4 Answers
+ 4
The concept of OOP is created to bring the real world closer to the programming world! Each item around you can be considered to be an object. For example: a BMW car A cute small cat a bank account Date Time and etc. Every object has its own attributes and behavior. What is an ATTRIBUTE? Each object has its own characteristics like shape, size, color and so on. We call these characteristics ATTRIBUTE. What is the BEHAVIOR of an object? Each object is created for a specific porpuse. Therefore the function which an object is supposed to do is called BEHAVIOR. Now... If you want to teach a computer what a cat is you should first define the concept of (animal). And then tell the computer that (cat) is an instance of the concept of animal. (🐈) is an instance of (animal) (🐕) is an instance of (animal) (🐘) is an instance of (animal) So animal is a classification and {🐈, 🐕, 🐘,...} Are instances of that Concept. So CLASS is an idea and OBJECT is an instance of that idea.
9th Feb 2019, 10:08 AM
Amir H.
Amir H. - avatar
+ 2
The structure and behavior of an object are defined by a class, which is a definition, or blueprint, of all objects of a specific type. An object must be explicitly created based on a class and an object thus created is considered to be an instance of that class. An object is similar to a structure, with the addition of method pointers, member access control, and an implicit data member which locates instances of the class (i.e., objects of the class) in the class hierarchy (essential for runtime inheritance features).
7th Feb 2019, 6:38 PM
BroFar
BroFar - avatar
+ 2
classes can be used to simply add namespaces to variables (attributes), functions (methods) and inner classes, but classes get a bigger meaning, if they have a consturctor. Objects can be created by classes, (by class constructors), in class constructors you can define the objects some special attributes, methods also magic methods, which are one of the best parts of OOP.
7th Feb 2019, 9:58 PM
Seb TheS
Seb TheS - avatar
+ 1
Class is a blueprint for objects. and object is an instance of a class through which we access to the methods and other features of a class.
7th Feb 2019, 7:34 PM
HAS|B
HAS|B - avatar