随机获取特定长度的素数(32bits)(拉宾米勒算法)
Ping (ICMP.dll) 简单实现

仿函数应用

ckfan posted @ 2012年10月26日 14:31 in 技术blog , 1089 阅读

从未接触过仿函数,这个也是这两天才接触的。它主要是一个class重载了“()”来达到目的。直接见代码吧

// 仿函数
struct max_class
{
public:
	int operator()(int x, int y)
	{
		return x > y ? x : y;
	}
};
template <class T>
int get_max(int x, int y, T t)
{
	return t(x,y);
}
int main()
{
      cout << get_max(11,2,max_class()) << endl;
}
Avatar_small
依云 说:
2012年10月26日 16:05

这个还有专门的名字啊……

seo service UK 说:
2024年2月24日 14:48

I exactly got what you mean, thanks for posting. And, I am too much happy to find this website on the world of Google


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter