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

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -