class ThresholdOp //阈值函数
{
public:
typedef SrcTT SrcT;
typedef TargetTT TargetT;
ThresholdOp(SrcT thre,TargetT s_val,TargetT l_val):m_thre(thre),m_s_val(s_val),m_l_val(l_val){};
inline void operator()(const SrcT& s_val,TargetT& t_val)
{
if ( s_val > m_thre )
t_val = m_l_val;
else
t_val = m_s_val;
}
private:
SrcT m_thre;
TargetT m_s_val;
TargetT m_l_val;
}
有没有例子能说明一下这个重载()的使用?
{
public:
typedef SrcTT SrcT;
typedef TargetTT TargetT;
ThresholdOp(SrcT thre,TargetT s_val,TargetT l_val):m_thre(thre),m_s_val(s_val),m_l_val(l_val){};
inline void operator()(const SrcT& s_val,TargetT& t_val)
{
if ( s_val > m_thre )
t_val = m_l_val;
else
t_val = m_s_val;
}
private:
SrcT m_thre;
TargetT m_s_val;
TargetT m_l_val;
}
有没有例子能说明一下这个重载()的使用?
解决方案
40
C++ 仿函数
去搜索一下你就明白了
去搜索一下你就明白了