C++ template memo
template うろおぼえだなぁ。動くかなとおもった次の物が動いた。int も class T で受けられる物なのか。
/* output: sizeof(4)=4 sizeof(2)=2 */ #include <iostream> using namespace std; template <class T> void afunc(T a) { cout << "sizeof(" << a << ")=" << sizeof(a) << endl; } int main(int argc, char *argv[]) { afunc<int>((int)4); afunc<short>((short)2); return 0; }