Saltar al contenido ForoHackers

C++: start here

C++
#3051 · · Citar · Denunciar

C++ extends C with classes, templates and a large standard library while keeping control of memory and cost. It is used where performance and resources matter: game engines, browsers, databases, trading systems and embedded software. It is a big language with several styles, and modern practice is to avoid the raw, C-like ways of managing memory.

Key concepts

  • RAII: resources such as memory, files and locks are owned by objects and released when they go out of scope.
  • Value semantics: copying, moving and ownership are explicit, with constructors, destructors and move operations.
  • Templates and generic programming: code written once for many types, resolved at compile time.
  • Standard library: containers, algorithms, strings and smart pointers, which replace most hand-written code.
  • Classes and polymorphism: inheritance and virtual functions for runtime dispatch, used with restraint.
  • Zero-cost abstraction: you do not pay for features you do not use.

Vocabulary

  • Smart pointer: an object that owns heap memory and frees it automatically.
  • Move semantics: transferring a resource instead of copying it.
  • Undefined behaviour: code the standard gives no meaning to, as in C.
  • Header and translation unit: how declarations are shared and compiled.

What to study, in order

  1. Basic C++ with the standard library: strings, vectors and maps, with no raw new or delete.
  2. Classes, constructors, destructors and RAII; write a small resource-owning class.
  3. Copy and move rules, and why smart pointers usually replace raw pointers.
  4. Templates: write a generic container and a function template.
  5. Standard algorithms and iterators; replace hand-written loops with them.
  6. Build a larger project with a build tool, warnings on and sanitisers enabled.

Related tags

#c #rust #memory-management #game-development

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder