http://user.qzone.qq.com/287555176/blog/1334813413?ptlang=2052#!app=2&pos=1334813413
高端程序员这样实现MAX
template <int x, int y>
struct Max
{
struct _X { char _[x]; };
struct _Y{ char _[y]; };
union _U { _X a; _Y b; };
enum { KResult = sizeof(_U), }
};
int i = Max<10, 100>::kResult;
虽然这样实例化 struct Max 对象后,有可能造成栈空间溢出.栈的默认空间是1M.
但这种对声明与定义的理解,却是很深刻的.