相关疑难解决方法(0)

C++ []数组运算符有多个参数?

我可以在C++中定义一个带有多个参数的数组运算符吗?我试过这样的:

const T& operator[](const int i, const int j, const int k) const{ 
    return m_cells[k*m_resSqr+j*m_res+i];
}

T& operator[](const int i, const int j, const int k){ 
    return m_cells[k*m_resSqr+j*m_res+i];       
}
Run Code Online (Sandbox Code Playgroud)

但是我收到了这个错误:

error C2804 binary operator '[' has too many parameters
Run Code Online (Sandbox Code Playgroud)

c++ arrays operators operator-keyword

51
推荐指数
5
解决办法
3万
查看次数

标签 统计

arrays ×1

c++ ×1

operator-keyword ×1

operators ×1