The first case won't work as is. The template parameter has to be known at compile time. So if you change this to constint x = 12; - it will be ok. That's why for example my_class<sizeof(int)> class1; will also work. In C++11 you can make more sophisticated things that can go into template parameters using the constexpr specifier.
Second case will work (remove a semicolon after 12 in your define though) because for the compiler it will be the same as your last one - the preprocessor will substitute NR with 12 before compilation starts.