title: How to allow template function to have friend(-like) access?
body: <p>How does one modify the following code to allow template function <code>ask_runUI()</code> to use <code>s_EOF</code> without making <code>s_EOF</code> public?</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;vector&gt;
  class AskBase {
  protected:
      std::string m_prompt;
      std::string m_answer; 
      virtual bool validate(std::string a_response) = 0;
  public:
      AskBase(std::string a_prompt):m_prompt(a_prompt){}
      std::string prompt(){return m_prompt;}
      std::string answer(){return m_answer;}
      static int const s_EOF = -99;
      static int const s_BACKUP = -1;
      static int const s_OK = 1;
      int ask_user();
  };
  template&lt;typename T&gt; class Ask : public AskBase{
  public:
      Ask(std::string a_prompt):AskBase(a_prompt){}
      bool validate(std::string a_response);
  };
  template&lt;&gt; bool Ask&lt;std::string&gt;::validate(std::string a_response){return true;}
  template&lt;&gt; bool Ask&lt;int&gt;::validate(std::string a_response){int intAnswer;
      return (std::stringstream(a_response) &gt;&gt; intAnswer);}
  int AskBase::ask_user(){
      for(;;){
          std::cout &lt;&lt; "Enter " &lt;&lt; m_prompt;
          std::string response;
          getline(std::cin, response);
          if (std::cin.eof())
              return s_EOF;
          else if (response == "^")
              return s_BACKUP;
          else if (validate(response)){
              m_answer = response;
              return s_OK;
          }
      }
      return s_EOF;
  }
  template&lt;typename T&gt; int ask_runUI(T&amp; a_ui){
      int status = AskBase::s_OK;
      for (typename T::iterator ii=a_ui.begin();
              status!=AskBase::s_EOF &amp;&amp; ii!=a_ui.end();
              ii+=((status==AskBase::s_BACKUP)?((ii==a_ui.begin())?0:-1):1)
          status = (*ii)-&gt;ask_user();
      return (status == AskBase::s_OK);
  }
  int main(){
      std::vector&lt;AskBase*&gt; ui;
      ui.push_back(new Ask&lt;std::string&gt;("your name: "));
      ui.push_back(new Ask&lt;int&gt;("your age: "));
      if (ask_runUI(ui))
          for (std::vector&lt;AskBase*&gt;::iterator ii=ui.begin(); ii!=ui.end(); ++ii)
              std::cout &lt;&lt; (*ii)-&gt;prompt() &lt;&lt; (*ii)-&gt;answer() &lt;&lt; std::endl;
      else
          std::cout &lt;&lt; "\nEOF\n";
  }
  </code></pre>