La vida esta allá avatar

Platicando más funciones en c++ (virtual, override)

dobro2020

Published: 23 Jun 2026 › Updated: 23 Jun 2026Platicando más funciones en c++ (virtual, override)

Platicando más funciones en c++ (virtual, override)

Estos últimos días estuve aprendiendo cómo funcionan los punteros y algunos métodos extra de c++ ya que este lenguaje tiene infinidad de cosas para aprender.
En mi caso aún soy muy novato con este lenguaje y solo sé hacer cosas sencillas pero gracias a la inteligencia artificial puedo entender con mayor rapidez cómo funcionan algunos métodos.

These past few days I've been learning how pointers work and some extra C++ methods, since this language has countless things to learn.
In my case, I'm still a complete beginner with this language and only know how to do simple things, but thanks to artificial intelligence, I can understand how some methods work more quickly.

overr.png
Para esta simple muestra de código lo único que hice fue crear Dos clases y que la clase hija herede a la clase padre esto se utiliza mucho en programación orientado a objetos para tener un rápido acceso a ciertas funciones y evitar la verbosidad pero aquí fue con fines de aprender.
Se va a poder ver en el código que ambas clases poseen prácticamente lo mismo y que si son la misma clase con las mismas funciones por más que la clase hija esté heredando la padre se debería ejecutarla padre.

For this simple code sample, all I did was create two classes and have the child class inherit from the parent class. This is commonly used in object-oriented programming to quickly access certain functions and avoid verbosity, but here it was for learning purposes. You'll see in the code that both classes have practically the same characteristics, and that if they are the same class with the same functions, even though the child class is inheriting from the parent, the parent class should be executed.

overr1.png
Pero para estos casos sé más más permite utilizar algo llamado virtual lo cual permite a la clase hija sobreescribir a la clase padre en aquellos lugares donde el código sea igual y además el uso de override que compara si el código de la clase hija es exactamente igual al código de la clase padre porque si no estuviera este override podrían existir errores silenciosos y al ser el mismo código que la clase padre no se ejecutaría el código de la clase hija y no podría saber si existe un error dentro de la clase hija.

But for these cases, I know more, it allows the use of something called virtual, which allows the child class to override the parent class in those places where the code is the same, and also the use of override, which compares if the code of the child class is exactly the same as the code of the parent class because if this override were not there, there could be silent errors and, being the same code as the parent class, the code of the child class would not be executed and it would not be possible to know if there is an error within the child class.

overr2.png

Leave Platicando más funciones en c++ (virtual, override) to:

Written by

Soy desarrollador de software

Read more #spanish posts


Best Posts From La vida esta allá

We have not curated any of dobro2020's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From La vida esta allá