#include #include using namespace std; class DemoT{ public: DemoT() { mySerial = ++serial; } int Serial() const { return mySerial; } static string Name() { string value = "I am a " + BASE_NAME + " and my number is "; value += to_string(MY_NUMBER); //cout << anum << endl; cout << "bnum is " << bnum << endl; return value; } void ReportAndChange(){ cout << "bnum is " << bnum << endl; bnum++; } static string Name2(); private: static const int MY_NUMBER{7}; static const string BASE_NAME; static const inline string OTHER_NAME{"Fred"}; int anum {5}; static inline int bnum{4}; static int cnum; static inline int serial{0}; int mySerial; }; // note no static here. const string DemoT::BASE_NAME{"A DemoT Class"}; int DemoT::cnum{11}; string DemoT::Name2(void) { return DemoT::Name()+ " too!"; } int main() { cout << "The name functions for DemoT: " << endl; cout << DemoT::Name() << endl; cout << DemoT::Name2() << endl; DemoT a,b; cout << " A's serial number is " << a.Serial() << endl; cout << " B's serial number is " << b.Serial() << endl; a.ReportAndChange(); b.ReportAndChange(); a.ReportAndChange(); return 0; }