C++ FAQ Celebrating Twenty-One Years of the C++ FAQ!!!
(Click here for a personal note from Marshall Cline.)
Section 11:
[11.7] OK, OK already; I won't explicitly call the destructor of a local; but how do I handle the situation from the previous FAQ?

[For context, please read the previous FAQ].

Simply wrap the extent of the lifetime of the local in an artificial block {...}:

void someCode()
    File f;
    ...code that should execute when f is still open...
  } f's destructor will automagically be called here!

  ...code that should execute after f is closed...