title: C++ friend function not working
body: <p>I am new to C++ and have been trying to get my head around classes in c++. Recently I tried out this program and instead of returning an integer 9, it returns some garbage value. Can someone please help me out</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstring&gt;
  #include &lt;math.h&gt;
  using namespace std;
  class abc;
  class xyz
  {
      int a;
  public:
      friend int add(xyz, abc);
      friend void setval(xyz, int, abc, int);
  
  
  };
  class abc
  {
      int b;
  public:
      friend int add(xyz, abc);
      friend void setval(xyz, int, abc, int);
  };
  
  int add(xyz V1, abc V2)
  { return (V1.a + V2.b);}
  void setval(xyz v1, int v11, abc v2, int v22)
  {v1.a = v11; v2.b = v22; }
  
  int main()
  {
      xyz A;
      abc B;
      setval(A, 4, B, 5);
      cout&lt;&lt;add(A, B)&lt;&lt;endl;
      return(0);
  }
  </code></pre>