I\'m trying to create a Data class whose objects each hold a unique ID.
Data
I want the 1st object\'s ID to be 1, the 2nd to be 2, etc. I must use a st
st
This:
class Data { private: static int ID; const int currentID; public: Data() : currentID(ID++){ } };
Besides a static counter, you also need an instance-bound member.