If you don’t want to use functions, use lamdas starting with C++11.
Lambdas are basically anonymous functions, which I think is what you want, you seem to not want to define be a separate function:
auto something = [&x]() {
std::cout << "Something had been done\n";
++x;
};
Then, you can call it:
something();