In Object Oriented Programming or POO, you have to distinguish two different concepts:
-
class : A class is a prototype or mold that indicates what characteristics they will have and how the elements created from that class will behave.
-
object : Objects are the elements created from the aforementioned classes. In some contexts or languages, the term instance is also commonly used
That is, from a class you can create infinite objects or instances.
Notice that the above definitions do not indicate where or how the object or instance is to be created and that is an irrelevant aspect in this case. In languages such as C ++, for example, you have the ability to choose whether the object will be created in the dynamic memory (heap) or in the stack of the program (stack):
class POO
{
// ...
};
int main()
{
POO a; // a se crea en el stack
POO* b = new POO; // b se crea en el heap.
delete b; // La memoria dinámica es necesario liberarla.
}
However, this does not have to be the case in all languages since each one has its own characteristics and the theory of object-oriented programming is independent of the language used.