C++ cool cheetsheet produced by ChatGPT to refresh your memory

chatGPT is really helpful tool to programmers. these cheetsheet were produced by chatGPT 3.5 to help refresh your memory. if you are advanced programmer or have background in other languages. it can help to look at simple one liners instead of going through long pages of documentations

Keep in mind, chatGPT sometimes produces inaccurate information and sometimes it hallucinates:

  • Declaration of variables: int a = 10;
  • Conditional statements: if (a == 10) { ... } else { ... }
  • Loops: for (int i = 0; i < 10; i++) { ... } or while (condition) { ... }
  • Functions: void myFunction(int arg1, double arg2) { ... }
  • Classes and objects: class MyClass { ... }; MyClass myObject;
  • Inheritance: class ChildClass : public ParentClass { ... }
  • Polymorphism: virtual void myFunction() { ... } and override keyword in child classes
  • Templates: template void myFunction(T arg) { ... }
  • Standard libraries: #include for input/output, #include for dynamic arrays, #include for string manipulation, and many others.
  • Pointers and references: int *ptr = &a; and int &ref = a;
  • Memory management: new and delete for dynamic memory allocation and deallocation
  • Exception handling: try { ... } catch (exceptionType e) { ... }
  • Namespaces: namespace myNamespace { ... }
  • Macros: #define MY_MACRO(value) (value * 2)
  • Preprocessor directives: #include for header files, #ifdef and #ifndef for conditional compilation
  • Operator overloading: operator+, operator-, etc. can be overloaded for custom classes
  • Type casting: static_cast, dynamic_cast, reinterpret_cast, and const_cast
  • Standard Template Library (STL): provides containers like vector, map, set, and algorithms like sort, find, and accumulate
  • File input/output: fstream for reading/writing to files
  • String streams: stringstream for parsing and formatting strings
  • Multi-threading: std::thread for creating threads, std::mutex for thread synchronization
  • Function objects: std::function for storing and invoking callable objects
  • Lambda expressions: [] (int a, int b) { return a + b; } for inline functions or function objects
  • Range-based for loop: for (auto x : myVector) { ... } for iterating over a range of values
  • Smart pointers: std::unique_ptr and std::shared_ptr for automatic memory management
  • Regular expressions: std::regex for pattern matching and search in strings
  • Type traits: std::is_integral, std::is_floating_point, and others for compile-time type analysis
  • Move semantics: std::move for efficient transfer of ownership of objects
  • Variadic templates: template void myFunction(Args... args) { ... } for functions that can take any number of arguments.
  • Type deduction: auto for automatic type deduction of variables and lambda expressions
  • Rvalue references: int &&rref = 42; for binding to temporaries and move semantics
  • User-defined literals: 42_milliseconds or 3.14_pi for custom literals of user-defined types
  • Initialization lists: {1, 2, 3} for initializing objects and containers
  • Uniform initialization: MyClass obj{1, "hello"}; for consistent initialization syntax
  • constexpr functions: constexpr int factorial(int n) { ... } for compile-time evaluation of functions
  • Type aliases: using myInt = int; for creating aliases for types or templates
  • Concepts: template concept MyConcept = ... for expressing requirements on template arguments
  • Modules: import myModule; for modularization of code and faster compilation
  • Co-routines: co_await and co_yield for implementing asynchronous code and generators.
  • esign patterns: C++ supports many design patterns such as the Singleton pattern, the Observer pattern, and the Factory pattern.
  • Multiple inheritance: C++ allows classes to inherit from multiple base classes, providing flexibility in class hierarchy design.
  • C++11 features: C++11 introduced new language features such as lambdas, range-based for loops, and smart pointers to improve expressiveness and safety of C++ code.
  • C++14 features: C++14 added new features such as binary literals, generic lambdas, and extended constexpr to further improve the language.
  • C++17 features: C++17 added new features such as structured bindings, constexpr if, and fold expressions to provide more powerful and expressive templates.
  • C++20 features: C++20 introduced new features such as concepts, coroutines, and modules to further improve the language.
  • Third-party libraries: C++ has a vast ecosystem of third-party libraries such as Boost, Eigen, and OpenCV that provide additional functionality for C++ developers.
  • IDEs: Integrated development environments (IDEs) such as Visual Studio, CLion, and Code::Blocks provide powerful tools for editing, debugging, and testing C++ code.
  • Here are some briefs about common C++ headers, Qt headers, controls, and external libraries:C++ headers:
    • : Input/output library for C++.
    • : STL container for dynamic arrays.
    • : STL container for strings.
    • : Input/output library for files.
    • : STL algorithms for containers.

    Qt headers:

    • : Main application class for Qt Widgets.
    • : Main application class for Qt Quick.
    • : Base class for all Qt Widgets.
    • : Base class for all Qt Quick items.
    • : Base class for all Qt Widgets layouts.
    • : Class for creating QML objects dynamically.

    Common Qt controls:

    • QLabel: Control for displaying text and images.
    • QLineEdit: Control for editing text.
    • QPushButton: Control for triggering actions.
    • QCheckBox: Control for toggling on/off states.
    • QRadioButton: Control for selecting a single option from a set.
    • QComboBox: Control for selecting one option from a drop-down list.
    • QSpinBox: Control for selecting a numeric value from a range.
    • QSlider: Control for selecting a numeric value from a range with a slider.
    • QTableView: Control for displaying data in a table format.

    External libraries:

    • Boost: Collection of libraries for C++, including support for smart pointers, regular expressions, and numerical algorithms.
    • OpenCV: Library for computer vision and image processing.
    • Eigen: Library for linear algebra.
    • Qt Charts: Library for creating charts and graphs in Qt applications.
    • Qt WebEngine: Library for embedding web content into Qt applications.
    • Qt Network: Library for network programming in Qt applications.
    • Qt Multimedia: Library for audio and video playback and recording in Qt applications.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.