#include #include class SomeObj { private: int* flag; public: SomeObj(int* a_flag) : flag(a_flag) { (*flag) |= 1; } ~SomeObj() { (*flag) |= 2; } }; int main() { int flag = 0; with (SomeObj obj(&flag)) { Assert(flag == 1, "No constructor?"); } Assert(flag == 3, "No destructor?"); flag = 0; with (SomeObj obj(&flag)) Assert(flag == 1, "No constructor?"); Assert(flag == 3, "No destructor?"); return 0; }