title: object as member variable
body: <p>hi i have faced an issue while accessing an object,</p>
  
  <p>in my program there are 2 classes class A and B</p>
  
  <p>class b has a member variable name, which kepts as private.and gettes/setter functions to access this variable(bcoz the variable is private).</p>
  
  <p>in Class A, has a member variable , object of class B b(private).And i have used a getter to get this object outside the class.</p>
  
  <p>now i want to set the name of object b using the object of class a.
  so created the following code, but i didnot working.</p>
  
  <p>please help me to solve this.</p>
  
  <pre><code>     // GetObject.cpp : Defines the entry point for the console application.
     //
  
     #include "stdafx.h"
    #include &lt;iostream&gt;
  
    class B
   {
     int name;
     public:
     int getname()
     {
       return name;
     }
     void SetName(int i)
     {
       name = i;
     }
    };
    class A
    {
     private:
     B b;
     public:
  
     B GetB()
     {
        return b;
     }
  
     };
  
  
     int _tmain(int argc, _TCHAR* argv[])
     {
     int ii = 10;
    A a;
    a.GetB().SetName(ii);
    std::cout&lt;&lt;" Value :"&lt;&lt;a.GetB().getname();
    getchar();
  return 0;
    }
  </code></pre>