incremented define?
c++, visual-studio-2008
Solution
If you don't need compile-time-constants, you could do something like this to enumerate classes:
int counter() {
static int i = 0;
return i++;
}
template<class T>
int id() {
static int i = counter();
return i;
};
class A {};
class B {};
int main()
{
std::cout << id<A>() << std::endl;
std::cout << id<B>() << std::endl;
}
Problem
Is there anyways to have a define increment every time you use it? For example ``` int a = ADEFINE; int b = ADEFINE; ``` a is 1 and b is 2.