#include class X { private: const char* name; public: X(const char* name) : name(name) { std::cout << "X \"" << name << "\" constructed" << std::endl; } ~X() { std::cout << "X \"" << name << "\" destructed" << std::endl; } }; int main() { for (int i = 0; i < 2; ++i) { X x1 = "x1 within for loop"; { X x2 = "x1 in the inner block"; X x3 = "x2 in the inner block"; } X x4 = "x4 at the end of the for loop"; } }