for (int i=0; i < bars.size(); ++i) { Bar::SubClass& bar = bars[i]; //Extract Method from Here bar.myInt = i; // To Here } } When you extract method you get: void MyMethod( Bar::SubClass& * &bar, int i ) { //Extract Method from Here bar.myInt = i; // To Here }