c++ - 重载运算符或生成函数 (C++)

标签 c++ operator-overloading

以下哪个更快?

方法一:

int foo (int A, int B) {

    // write equations
}

方法二:

int operator| (int A, int B) {

    // write equations
}

最佳答案

执行速度没有区别。

选择只是风格和可读性之一。您应该选择最易于理解的代码,以帮助日后维护。

关于c++ - 重载运算符或生成函数 (C++),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9115941/

相关文章:

c++ - 使用gdb调试时如何解决VS Code中: "launch : program "executable. out"does not exist"

c++ - 增强精神解析器: getting around the greedy kleene *

haskell - 使用具有约束字段的数据类型代替约束

c++ - 重载数学运算符

c++ - 将复杂对象传递给 C++ 中的函数,但数组订阅运算符无法正常工作

c++ - 来自 unsigned char 缓冲区的 QImage(jpg 格式)

c++ - 如何使用许多模板参数简化符号并将其用于 C++ 中的另一个模板类

c++ - 在 Windows 上跟踪移动到回收站的进度

c++ - C++ 中的一元运算符重载类型(新手)

operator-overloading - 定义 equals() 运算符的问题