why C++ template function do not support returning a pointer? : <p>I have a function like this:</p>

<pre><code>#include &lt;iostream&gt;


using namespace std;

// function to generate and retrun random numbers.
template&lt;typename T&gt;
T * getRandom( ) {
   static T  r[10];


   for (int i = 0; i &lt; 10; ++i) {
      r[i] = 111;
      cout &lt;&lt; r[i] &lt;&lt; endl;
   }

   return r;
}

// main function to call above defined function.
int main () {
   // a pointer to an int.
   int *p;

   p = getRandom();
   for ( int i = 0; i &lt; 10; i++ ) {
      cout &lt;&lt; "*(p + " &lt;&lt; i &lt;&lt; ") : ";
      cout &lt;&lt; *(p + i) &lt;&lt; endl;
   }

   return 0;
}
</code></pre>

<p>However, when I compile the code using g++5.4 and c++11. The compiler gives me this error:</p>

<pre><code>main.cpp: In function 'int main()':
main.cpp:25:18: error: no matching function for call to 'getRandom()'
    p = getRandom();
                  ^
main.cpp:25:18: note: candidate is:
main.cpp:8:5: note: template&lt;class T&gt; T* getRandom()
 T * getRandom( ) {
     ^
main.cpp:8:5: note:   template argument deduction/substitution failed:
main.cpp:25:18: note:   couldn't deduce template parameter 'T'
    p = getRandom();
              ^
</code></pre>

<p>It seems that C++ does not support to return a pointer that point to a template?</p>

<p>Could anyone please tell me what's wrong with my toy example, thanks in advance!!</p>
