#include <iostream>
struct Foo {
Foo( int init )
: value( init )
{ }
int value;
};
int main() {
Foo foo( 2 );
// write
int new_values[] = { 1, 1, 1, 2, 3, 3 };
size_t const size = sizeof(new_values) / sizeof(*new_values);
for( size_t i = 0; i != size; ++i ) {
std::cout << "set in index: " << i << std::endl;
foo.value = new_values[ i ];
}
// read
std::cout << "final value: " << foo.value << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgogCnN0cnVjdCBGb28gewogICAgRm9vKCBpbnQgaW5pdCApCiAgICA6IHZhbHVlKCBpbml0ICkKICAgIHsgfQogICAgCiAgICBpbnQgdmFsdWU7ICAKfTsKIAppbnQgbWFpbigpIHsKICAgIAogICAgRm9vIGZvbyggMiApOwogICAgLy8gd3JpdGUKICAgIGludCBuZXdfdmFsdWVzW10gPSB7IDEsIDEsIDEsIDIsIDMsIDMgfTsKICAgIHNpemVfdCBjb25zdCBzaXplID0gc2l6ZW9mKG5ld192YWx1ZXMpIC8gc2l6ZW9mKCpuZXdfdmFsdWVzKTsKICAgIAogICAgZm9yKCBzaXplX3QgaSA9IDA7IGkgIT0gc2l6ZTsgKytpICkgewogICAgICAgIHN0ZDo6Y291dCA8PCAic2V0IGluIGluZGV4OiAiIDw8IGkgPDwgc3RkOjplbmRsOwogICAgICAgIGZvby52YWx1ZSA9IG5ld192YWx1ZXNbIGkgXTsKICAgIH0KIAogICAgLy8gcmVhZAogICAgc3RkOjpjb3V0IDw8ICJmaW5hbCB2YWx1ZTogIiA8PCBmb28udmFsdWUgPDwgc3RkOjplbmRsOwp9