Hasty Briefsbeta

Bilingual

Modern C++ for C programmers: part 2 - Bert Hubert's writings

a day ago
  • Namespaces in C++ allow avoiding name collisions, with the standard library living in the std:: namespace.
  • Classes are essentially C structs with member functions, using a hidden 'this' pointer for method calls.
  • RAII (Resource Acquisition Is Initialization) uses constructors and destructors to automatically manage resources like file handles.
  • Smart pointers like std::shared_ptr and std::unique_ptr provide automatic memory management with reference counting or zero overhead.
  • C++ offers std::async and std::thread for easy thread creation, and std::atomic for atomic operations.
  • Locking with std::lock_guard ensures mutexes are released automatically via RAII.
  • Exceptions provide a way to handle errors that cannot be ignored, combined with RAII for safe resource cleanup.