Operator[][] overload

前端 未结 18 1837
轮回少年
轮回少年 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

    struct test
    {
        using array_reference = int(&)[32][32];
    
        array_reference operator [] (std::size_t index)
        {
            return m_data[index];
        }
    
    private:
    
        int m_data[32][32][32];
    };
    

    Found my own simple solution to this.

提交回复
热议问题