+ 2
Object Oriented Programming
Hi, can you explain these keywords: Class Objects What's the difference between these two?!
4 Respostas
+ 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.
+ 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).
+ 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.
+ 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.