c++ - How does subscripting std::array multiple times work? -
how subscripting multiple times work std::array
though operator[]
returns reference, without using proxy-objects (as shown here)?
example:
#include <iostream> #include <array> using namespace std; int main() { array<array<int, 3>, 4> structure; structure[2][2] = 2; cout << structure[2][2] << endl; return 0; }
how/why work?
you call structure.operator[](2).operator[](2)
, first operator[]
returns reference third array in structure
second operator[]
applied.
note reference object can used object itself.
Comments
Post a Comment