Difference in behavior when returning a local reference or pointer
<pre><code>#include &lt;iostream.h&gt;
using namespace std;

class A {
public:
   virtual char* func()=0;
};

class B :public A {
public:
   void show() {
      char * a;
      a = func();
      cout &lt;&lt; "The First Character of string is " &lt;&lt; *a;
   }
   char * func();
};


char* B::func() {
   cout &lt;&lt; "In B" &lt;&lt; endl;
   char x[] = "String";
   return x;
}

int main() {
   B b;
   b.show();
}
</code></pre>

<p>The problem in this is that I am returing a local varibale pointer/reference.
Currently it is <code>char x[]="String"</code>, but when I use a pointer <code>char *x="String"</code>, the result is <code>"S"</code>  but when Array reference the output comes as (i)</p>
