Operator[][] overload

前端 未结 18 1806
轮回少年
轮回少年 2020-11-22 05:46

Is it possible to overload [] operator twice? To allow, something like this: function[3][3](like in a two dimensional array).

If it is pos

18条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 06:30

    My 5 cents.

    I intuitively knew I need to do lots of boilerplate code.

    This is why, instead of operator [], I did overloaded operator (int, int). Then in final result, instead of m[1][2], I did m(1,2)

    I know it is DIFFERENT thing, but is still very intuitive and looks like mathematical script.

提交回复
热议问题