Papers/programming

template inline

tomato13 2008. 5. 27. 19:40

http://blog.naver.com/smurfe380?Redirect=Log&logNo=150007620014

 

http://blog.naver.com/dkskwjdu54?Redirect=Log&logNo=130020583096

 

ex)

 

// define 구현부분

#define min(a,b) (((a) < (b)) ? (a) : (b)) 

 

// tamplate 구현 부분

template<class T> inline const T& min(const T& v1, const T& v2)
{
    return (v1 < v2 ? v1 : v2);
}

 

// 실질 사용 부분

int i=3, j=7, k=0;

k = min(i,j);

 

'Papers > programming' 카테고리의 다른 글

try, catch and throw statements  (0) 2008.05.28
malloc vs. new  (0) 2008.05.28
Template class  (0) 2008.05.27
auto_ptr  (0) 2008.05.26
new & delete overloading  (0) 2008.05.26