C++ multidimensional array operator

后端 未结 7 1373
栀梦
栀梦 2021-01-05 16:22

it is possible to overload somehow operator for multidimensional array?

Something like:

class A {
  ...
  int& operator[][] (const int x, const i         


        
7条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-05 16:32

    No, there's just operator[]. As an alternative, you can overload:

    int &operator()(int x, int y);
    

    You can use that:

    m(4, 5);
    

提交回复
热议问题