长风破浪会有时,直挂云帆济沧海

Dream Word

博客园 首页 新随笔 联系 订阅 管理

/****/

//求两个int值得最大值

inline int const& max(int const& a,int const& b)

{

  return a<b?b:a;

}

//求两个任意类型值中的最大值

template <typename T>

inline T const& max(T const& a,T const& b)

{

  return a<b?b:a;

}

//求三个任意类型值中的最大者 

tempalte <typename T>

inline T const& max(T const& a,T const& b,T const& c)

{

  return ::max(::max(a,b),c);

}

//求两个指针所指向值得最大者

template <typename T>

inline T* const& max(T* const& a,T* const& b)

{

  return  *a < *b ? b:a;

}

//求两个C字符串的最大值

inline char const* const& max(char const* const& a,char const* const& b)

{

  return std::strcmp(a,b) < 0 ? b:a;

}

posted on 2017-03-04 18:33  长风II  阅读(371)  评论(0编辑  收藏  举报