Setting Up Door Open/Close In C++

So After looking through this, it seems pretty simple. I can pretty easily get this to work, but it looks almost identical to what I would do in c++. Is doing it this way more efficient in some way? Or is it simply due to ease?