会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
不凡
思想创造世界
学习STL Functor时候的测试程序
#include
<
iostream
>
using
namespace
std;
template
<
typename T
>
class
plus
{
public
:
T
operator
()(
const
T
&
x,
const
T
&
y)
const
{
return
(x
+
y);
}
}
;
template
<
typename T
>
class
minus
{
public
:
T
operator
()(
const
T
&
x,
const
T
&
y)
const
{
return
(x
-
y);
}
}
;
int
main(
int
argc,
char
*
argv[])
{
plus
<
int
>
plusobj;
minus
<
int
>
minusobj;
cout
<<
plusobj(
3
,
5
)
<<
endl;
cout
<<
minusobj(
3
,
5
)
<<
endl;
cout
<<
plus
<
int
>
() (
43
,
50
)
<<
endl;
cout
<<
minus
<
int
>
() (
43
,
50
)
<<
endl;
return
0
;
}
posted on
2005-05-13 09:52
hunter_gio
阅读(
420
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
导航
博客园
首页
新随笔
联系
订阅
管理
公告