[
Example 1:
In the following program,
the elements of a are destroyed,
followed by dt, and
finally by the two Btemp objects:
struct DTemp { ~DTemp(); };
struct Temp {
~Temp() {
static DTemp dt;
}
};
struct BTemp {
~BTemp();
};
struct A {
const BTemp &tb;
~A();
};
A a[] = { (Temp(), BTemp()), BTemp() };
int main() {}
If the array
a were an object with automatic storage duration,
the
Btemp temporaries would be destroyed
as each element of the array is destroyed (
[class.temporary])
. —
end example]