unique-id

in C++, how to use a singleton to ensure that each class has a unique integral ID?

I have a bunch of C++ classes. I want each class to have something like: static int unique_id; All instances of a same class should have the same unique_id; different classes should have different unique_id's. The simplest way to do this appears to be threading a singleton through the classes. However, I don't know what's called w...

Unique Numerical ID for a Templated Class using Function Address

So, this question has been asked before, but I wanted a question with some of those key words in the title. The issue is simple: How can I have a templated class, such that for each instance of the template - but not each instance of the class - there is a unique, numerical identifier? That is, a way to differentiate: foo<int> f1; foo...

SQL (Java, h2): What's the best way to retrieve the unique ID of the single item I just inserted into my database?

My current method is this: SELECT TOP 1 ID FROM DATAENTRY ORDER BY ID DESC This assumes the latest inserted item always has the highest unique ID (primary key, autoincrementing). Something smells wrong here. Alternatives? ...