#include <vector>
using std::size_t;

struct Foo {
   std::vector<int> bars;
   int& operator[](size_t idx) {
      return bars[idx];
   }
};

class Bar {
   Foo *foo; //some initialization

   int& helper(size_t idx) {
      return (*foo)[idx];
   }

   void barfoo() {
      size_t baz = 1;
      int qux;

      //solution 1
      qux = (*foo)[baz];  //works
      (*foo)[baz] = 1;    //works

      //solution 2
      qux = helper(baz);  //works
      helper(baz) = 1;    //does not work: "expression is not assignable"
   }     
};

int main() {}
