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;
}
相关文章:
- 为什么随机数生成器不在void函数中随机化数字,而在main函数中随机化
- 代码在main()中运行,但在函数中出现错误
- 当我在main中声明了我的2d数组时,为什么我的程序会退出
- QML:修改在不同QML文件(而非main.QML)中定义的子对象的属性
- 不确定要在我的main中放入什么才能使我的代码正常工作
- 函数是否可以访问传递给main()的参数
- 在main()之外初始化std::vector会导致性能下降(多线程)
- 我的 int main() 中出现堆栈溢出错误
- C++变量名(可以将 main 声明为变量,但对于其他函数名称则不然)
- 当我尝试在 Main 中调用插入函数时,它不是取数字?
- File.cpp.o:OpenPose 标志 CMakeFiles/.. 的多重定义/main.cpp.o:首先在这里定
- 为什么类和 main() 函数中也有动态内存分配
- 在 main.cpp 的上下文中找不到目录(带有 CMake 的快板)
- 我想在 Main 中用 C++ 调用其他类中的一个类,但我做不到
- "main"函数堆栈中的对象在第一个任务运行时被覆盖 (FreeRTOS)
- 为什么 'main' 函数中的局部 int 变量会自动初始化?
- C++ assigment std::list:<typename>:itrator 在 main 中工作,但在方法中它不起作用
- 为什么在我的 main 函数中声明整数后我的整数数组中会出现错误?
- 为什么要从main()返回NULL?
- main() 中的 std::cout 在调试期间不会在调试控制台中打印任何内容