Aprendiendo a utilizar archivos de cabecera en c++

Cuando tengo algún tiempo libre aprovecho a seguir estudiando con c++ que es un lenguaje que ofrece bastantes cosas pero tuve que mudarme de editor de código a visual studio la razón de esto es muy simple porque este editor de código ofrece El compilador en tiempo real y muestra los errores con más detalles para evitar que yo tenga que estar organizando todas las carpetas de los archivos.

Cuando tengo algún tiempo libre aprovecho a seguir estudiando con c++ que es un lenguaje que ofrece bastantes cosas pero tuve que mudarme de editor de código a visual studio la razón de esto es muy simple porque este editor de código ofrece El compilador en tiempo real y muestra los errores con más detalles para evitar que yo tenga que estar organizando todas las carpetas de los archivos.

header1.png
La ventaja de trabajar con archivos de cabecera es que puedo utilizar clases y funciones inicialmente declaradas de manera público privada en archivos específicos evitando tener que volver a crearlas en el archivo principal.
Esto al principio me sonó un poco complejo pero tiene una manera de trabajar mucho más sencilla porque tendría dos archivos uno que si es de cabecera y el otro el que ejecuta el código de esa cabecera.

The advantage of working with header files is that I can use classes and functions initially declared publicly or privately in specific files, avoiding having to recreate them in the main file.
This initially sounded a bit complex, but it has a much simpler way of working because you would have two files: one that is the header file and the other that executes the code in that header file.

header2.png
header3.png
De manera resumida sería como declarar el nombre de la función rellenar los datos de la función en el otro archivo y por último ejecutarlo a todo esto en el archivo principal lo cual demuestra que tiene una jerarquía y un sentido de ejecución las cosas y haría mucho más fácil corregir el código a futuro o permitir que crezca de manera eficiente.
Para este caso simplemente utilicé una clase que tiene funciones públicas y un valor privado mientras que el archivo que ejecuta esas funciones retorna valores y mensajes por la terminal.

In short, it would be like declaring the function name, filling in the function's data in another file, and finally executing it all in the main file. This demonstrates a hierarchy and a logical execution sequence, making it much easier to correct the code in the future or allow it to grow efficiently.
In this case, I simply used a class with public functions and a private value, while the file that executes those functions returns values ​​and messages to the terminal.>

header4.png
Al final en el archivo principal lo único que tengo que hacer es instanciar la clase creando un nuevo objeto al cual llamé con la letra p y el código se volvió mucho más corto y fácil de utilizar.

In the end, in the main file, all I have to do is instantiate the class by creating a new object which I called with the letter p, and the code became much shorter and easier to use.



0
0
0.000
1 comments
avatar

Congratulations @dobro2020! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You distributed more than 30000 upvotes.
Your next target is to reach 31000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

0
0
0.000