Modernes C++ programmieren

Okt 23, 2024

lst-0321-book.cpp

// https://godbolt.org/z/b9arcEMM1 
constinit auto SZ = 10*1000-1;                 // globale Variable
size_t autoincrement() {
    static constinit size_t i = 0;             // lokale statische Variable
    return i++;
}
class BraitenbergVehicle {
    inline static constinit size_t count_ = 0; // Klassenvariable
public:
    size_t id_;
    BraitenbergVehicle() : id_{++count_} {}
    ~BraitenbergVehicle() { --count_; }
};