c++ - 一个重载的函数调用运算符可以有多少个操作数?

标签 c++ operators operator-overloading

Exercise 14.33: How many operands may an overloaded function-call operator take?

这是我正在阅读的 C++ Primer 5th Edition 中的一个问题。

也来自本书:

An overloaded operator function has the same number of parameters as the operator has operands.(Section 14.1)

来自 another thread on SO :

— Parameters in one function definition [256]. 
— Arguments in one function call [256]. 

只是确认一下,256 是这个问题的答案吗?

最佳答案

不是真的。两者都可以至少有 256 个。

已在 Maximum number of parameters in function declaration 上讨论过.

The limits may constrain quantities that include those described below or others. The bracketed number following each quantity is recommended as the minimum for that quantity. However, these quantities are only guidelines and do not determine compliance.

— Parameters in one function definition [256].

— Arguments in one function call [256].

关于c++ - 一个重载的函数调用运算符可以有多少个操作数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21211889/

相关文章:

c# - VS2015 — 将 CRL 与 C++ DLL 链接起来

c++ - localtime 和 mktime 的时间戳问题

c++ - 在 Linux 中使用原始套接字时,802.3 header 长度始终为 256

c++ - 如何从重载的下标 [] 运算符返回 std::unique_ptr?

templates - 使用多个模板的运算符重载

c++ - 将 bitset 成员函数 count 的输出放入 vector 中很慢

c++ - 在 map 中搜索值时不匹配 'operator='

javascript - JavaScript 有等同于 ? : operator?

java - i=i++ 中的操作顺序;

c++ - 有没有办法向原始类型添​​加转换运算符?