main中的函子示例

example of a functor in main

本文关键字:main      更新时间:2023-10-16

我有一个类Bill,我在这个类中写了这个函子

//functor 
    bool operator==(const Bill& other) const;
    void operator()(int x) { sumCost -= x; }

我不知道的是如何在main中使用它。

谢谢你的帮助!

在main中使用与在其他函数中使用相同:

int main()
{
    Bill b;
    b( 123 );
    return 0;
}