If you want a template function to be a friend, you must say so in the class declaration. Change the line that declares the friend function to this:
template <typename T>
friend int ask_runUI(T& a_ui);
Now, if your class is itself a template, things get a lot more complicated. Template friends are not trivial to do correctly. For that, I'll refer you to what C++ FAQ Lite says on the subject.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…