title: Including a class object inside another class c++
body: <p>I am having trouble calling a method on an object created inside another classes private scope.
  The error is down the bottom as well. It seems like it is not recognising the Motor variables inside my car class.</p>
  <p>Do I need to create them as pointers? Or is there something else I am missing here?</p>
  <p>This is to be used in an Arduino project.</p>
  <p>Motor.h:</p>
  <pre><code>    /*
   * Library for turning a motor
   * turns forward reverse and stops
   */
  #ifndef Motor_h
  #define Motor_h
  
  class Motor {
    private:
      int _fPin;
      int _bPin;
    public:
      Motor();
      void init(int fPin, int bPin);
  
      void forward();
  
      void back();
  
      void brake();
  };
  
  #endif
  </code></pre>
  <p>Car.h</p>
  <pre><code>#include &quot;Motor.h&quot;
  
  class Car
  {
    private:
      Motor rMotor;
      Motor lMotor;
      float degPerMs = 4.44;
  
    public:
    
      Car(int forR, int revR, int forL, int revL);
  
      void forward();
  
      void reverse();
  
      //input from -180 to 180
      void turn(int angle);
  
      void brake();
  };
  </code></pre>
  <p>Car.cpp;</p>
  <pre><code>#include &quot;Car.h&quot;
  #include &quot;Motor.h&quot;
  #include &quot;Arduino.h&quot;
  
  Car::Car(int forR, int revR, int forL, int revL)
  {
      rMotor.init(int forR, int revR);
      lMotor.init(int forL, int revL);
  };
  
  Car::forward()
  {
      rMotor.forward();
      lMotor.forward();
  }
  
  Car::reverse()
  {
      rMotor.back();
      lMotor.back();
  };
  
  Car::turn(int angle)
  {
  
      float onTime = abs(angle) * degPerMs;
  
      if (angle &lt; 0)
      {
          rMotor.forward();
          lMotor.back();
          delay(onTime);
          rMotor.brake();
          lMotor.brake();
      }
      else
      {
          lMotor.forward();
          rMotor.back();
          delay(onTime);
          rMotor.brake();
          lMotor.brake();
      }
  };
  
  Car::brake()
  {
      lMotor.brake();
      rMotor.brake();
  };
  </code></pre>
  <p>errors</p>
  <pre><code>D:\4. Study\Deakin\2nd Year\Trimester 2\SIT217 - Engineering 1 Robotics Project\2. Project\main\Car.cpp: In constructor 'Car::Car(int, int, int, int)':
  Car.cpp:7:17: error: expected primary-expression before 'int'
       rMotor.init(int forR, int revR);
                   ^~~
  Car.cpp:7:27: error: expected primary-expression before 'int'
       rMotor.init(int forR, int revR);
                             ^~~
  Car.cpp:8:17: error: expected primary-expression before 'int'
       lMotor.init(int forL, int revL);
                   ^~~
  Car.cpp:8:27: error: expected primary-expression before 'int'
       lMotor.init(int forL, int revL);
                             ^~~
  exit status 1
  expected primary-expression before 'int'
  </code></pre>