title: c++ change an object value in another class
body: <p>I'd like to change the object <code>brain</code> in class <code>Robot</code>, not in <code>main</code> function. But the <code>brain.brainData = 11;</code> gives me an error:</p>
  <pre><code>class_constructor_another.C:11:3: error: ‘brain’ does not name a type
     brain.brainData = 11; //something wrong
  </code></pre>
  <p>Here is the full code:</p>
  <pre><code>#include &lt;iostream&gt;
  class RobotBrain{ 
  public: 
    int brainData = 10;
    void process() { std::cout&lt;&lt;&quot;Do some process&quot;&lt;&lt;std::endl; } 
  }; 
   
  class Robot{ 
  public:
    RobotBrain brain;
    brain.brainData = 11; //something wrong
    void processInformation(){ 
      brain.process(); 
    }
    
  }; 
   
  int main() 
  { 
    Robot myRobot; 
    myRobot.processInformation();
    myRobot.brain.brainData = 12; //this works
    std::cout&lt;&lt;myRobot.brain.brainData&lt;&lt;std::endl;
    
  }
  </code></pre>