title: The program is running but resulting in garbage values for executive display
body: <pre><code>#include&lt;iostream.h&gt;
  #include&lt;conio.h&gt;
  #include&lt;stdio.h&gt;
  class employee
  {
  protected:
      char nm[30];
      float sal;
  };
  class manager:public employee
  {
  protected:
      char dep[10];
  public:
      void input();
      void disp();
  };
  void manager::input()
  {
      cout&lt;&lt;"enter name";
      gets(nm);
      cout&lt;&lt;"enter salary";
      cin&gt;&gt;sal;
      cout&lt;&lt;"enter dep";
      gets(dep);
  }
  void manager::disp()
  {
      cout&lt;&lt;endl&lt;&lt;"manager name:"&lt;&lt;nm&lt;&lt;endl;
      cout&lt;&lt;"salary:"&lt;&lt;sal&lt;&lt;endl;
      cout&lt;&lt;"deptmt:"&lt;&lt;dep&lt;&lt;endl;
  }
  class executive:public manager
  {
  public:
      void disp();
  };
  void executive::disp()
  {
      cout&lt;&lt;endl&lt;&lt;"executive"&lt;&lt;endl;
      manager::disp();
  }
  int main()
  {
      manager m1;
      m1.input();
      executive e;
      m1.disp();
      e.disp();
      return 0;
  }
  </code></pre>
  
  <p>The code appears to be running fine... but it's showing garbage values for the display of executiv, even though display and input of manager is doing well. Kindly suggest me the problem with the code.</p>