Another approach is that object's available methods cannot change over time, but this requires move semantics: `close(file)` consumes `file`, so you can't invoke anything else on it.
Rust has this built-in (lifetimes and move / borrow semantics); I suppose C++ can model this, too.