The need to add a serial number unique across all instances of all derived classes must come up frequently. But I can't find a sample. Or a match to my search of stackoverflow.
If I instantiate a bird, mammal and worm from three classes all derived from Animal, the SN values should be 1,2,3. And then an instance of canine (derived from mammal) should get SN 4. And then next bird gets SN 5.
I've tried several ways and they all fail, so rather than troubleshooting, can someone point me to a good design pattern?
Thanks.