问题描述
我想在 cpp 中实现 puthon 列表,bug 没有找到实现 pyton 切片运算符的方法,例如:
list[3:7] // sublist including item 3 included to item 7 excluded
由于冒号不是 cpp 中的运算符,我们不能重载它。所以我改变了我的实现以使用可重载的逗号,例如list[3,7]
。我想我首先需要重载逗号运算符,然后重载 [ ]
运算符
但是我在用 2 个整数重载 [ ]
时出错:
Error is : operator[](int,int) must have exactly one argument
请帮我解决问题。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)