#include <iostream>

template <int>
struct Inc
{
    enum { value = 0 };
};
    
template <int index>
struct Id
{
	enum { value = Id<index - 1>::value + Inc<index - 1>::value };
};

template <>
struct Id<0>
{
	enum { value = 0 };
};

#define CLASS_DECLARATION(Class) \
template <> \
struct Inc<__LINE__> \
{ \
	enum { value = 1 }; \
}; \
 \
struct Class \
{ \
	enum { id = Id<__LINE__>::value }; \
private:

CLASS_DECLARATION(A)
    // ...
};

CLASS_DECLARATION(B)
    // ...
};

CLASS_DECLARATION(C)
    // ...
};

int main()
{
    std::cout << A::id << std::endl;
	std::cout << B::id << std::endl;
	std::cout << C::id << std::endl;
}