The object is not destroyed, but the name obj isn’t available inside reg() – that’s just what you named your object inside main().
You can refer to the current object inside member functions via *this, but you can also access members directly.
2
solved Why can’t I refer to an instance of a class by name within a method? [closed]