Skip to the content ForoHackers
Log inJoin

C++: start here

C++
#3051 · · Quote · Report

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

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply