我想知道,如果我可以重用指针到循环块内的变量.
int *ptr = nullptr; for (int i = 0; i < 5; ++i) { int j = 5; if (!ptr) ptr = &j; cout << *ptr << endl; }
我相信这段代码适用于所有编译器,但它是否符合标准?
c++ scope lifetime
c++ ×1
lifetime ×1
scope ×1