title: calling an Object constructor from my class
body: <p>I'm having some difficulties understanding how to convert my &quot;regular&quot; code into &quot;Object oriented&quot; code.</p>
  <p>My code is for Arduino, but the question is generic enough, so no Arduino specific details are relevant to the question.</p>
  <p>In my &quot;regular&quot; code I just import a library, call a constructor with some parameters to create the object, and then call the method begin</p>
  <pre><code>#include &lt;Adafruit_NeoPixel.h&gt;
  #define NPIXELS 10
  #define PIN 3
  #define FREQ 10000
  
  void main() {
      Adafruit_NeoPixel pixels(NPIXELS, PIN, FREQ);
      pixels.begin();
  }
  </code></pre>
  <p>Now, I'm building my own class, and inside I want to use Adafruit_NeoPixel, so basically I do:</p>
  <pre><code>// MyDevice.h 
  
  class MyDevice {
  public:
      MyDevice();  // constructor
  private:
      // this fails, I cannot call the constructor with parameters here
      // Adafruit_NeoPixel pixels(NPIXELS, PIN, FREQ);
  
      // this compiles, so I just define pixels as an Adafruit_Neopixel object
      Adafruit_NeoPixel pixels;
  }
  
  
  // MyDevice.cpp
  #include &quot;MyDevice.h&quot;
  
  MyDevice::MyDevice() {  // constructor
     // here I need to call the constructor of Adafruit_NeoPixel 
     // with the parameters NPIXELS, PIN and FREQ
     
     // This fails
     // no match for call to '(Adafruit_NeoPixel) (int, int, int)
     this-&gt;pixels(NPIXELS, PIN, FREQ);
  
     // This also fails
     // no match for call to '(Adafruit_NeoPixel) (int, int, int)
     pixels(NPIXELS, PIN, FREQ);
  
     // This compiles, but I am not sure if here I am using the
     //   pixels object defined in the .h file or I am just 
     // creating a new object inside the constructor.
     // If I remove the pixels definition from the h file it 
     // still compiles, which is suspicious
     Adafruit_NeoPixel pixels(NPIXELS, PIN, FREQ);
  }
  </code></pre>
  <p>So, my question is:
  How can I create the object pixels inside my class and initialize it calling the right constructor (the one with 3 params: NUMPIXELS, PIN, FREQ)</p>
  <p>Thanks</p>