How to force the hair mesh to follow animation?

Your Solution works but only when the game is in play mode.
In the editor the hairs and the head socket is still not welded.
I have tried with the blueprints and works perfectly but I want the same thing to achieve in C++ code.