gpt4 book ai didi

c++ - 错误 : postfix ‘unaryOperators unaryOperators::operator++(const unaryOperators&)’ must take ‘int’ as its argument

转载 作者:太空狗 更新时间:2023-10-29 19:40:51 25 4
gpt4 key购买 nike

unaryOperators operator++ (const unaryOperators &one);
对于在类中声明的这个,我应该得到错误“参数太多”等,但我得到的错误是:

错误:后缀“unaryOperators unaryOperators::operator++(const unaryOperators&)”必须将“int”作为其参数

为什么必须将“int”作为参数?这是什么意思?

海湾合作委员会Linux

最佳答案

来自 here :

Since the prefix and postfix ++ operators can have two definitions, the C++ language gives us two different signatures. Both are called operator++(), but the prefix version takes no parameters and the postfix version takes a dummy int.

关于c++ - 错误 : postfix ‘unaryOperators unaryOperators::operator++(const unaryOperators&)’ must take ‘int’ as its argument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8711953/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com