user21020: I am far from being an Arduino specialist, so please bear with me if some of my code below is far from correct.
I am writing a sketch in which I need to use 3 instances of the HX711 library, as I am using 3 different weight sensors.
In order to try to clean up the code, I want to put basically all the code using HX711 in my own class.
Here is what my ScaleMeasure.h looks like:
// ScaleMeasure.h
#ifndef _SCALEMEASURE_h
#define _SCALEMEASURE_h

#if defined(ARDUINO) && ARDUINO >= 100
    #include "arduino.h"
#else
    #include "WProgram.h"
#endif

#include <CmdMessenger.h>
#include "HX711.h"

class ScaleMeasure
{
 public:
    ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID); 
    void Setup();   
    float Measure();    

private:
    int _dout_pin;
    int _clk_pin;
    float _calibration_factor;
    byte _scaleID;
    HX711 _scale = HX711(_dout_pin, _clk_pin);  
};

and .cpp
#include "ScaleMeasure.h"

ScaleMeasure::ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID)
{
    _clk_pin = Clk;
    _dout_pin = Dout;   
    _calibration_factor = CalibF;
    _scaleID = ScaleID;     
}

void ScaleMeasure::Setup()
{       
    _scale.power_up();
    _scale.set_scale();
    _scale.set_scale(_calibration_factor);
    _scale.tare();
    _scale.read();
}

float ScaleMeasure::Measure()
{   
    return _scale.get_units(5);
}

but there is obviously something wrong, as a call to the constructor lock the rest of the program. I believe that my instantiation, of HX711 in ScaleMeasure.h  HX711 _scale = HX711(_dout_pin, _clk_pin); is not correct, or not in the right place. The code compile fine, though.
Thanks for your help.

user13594: Unfortunatly HX711 has no default constructor. So the easiest way would be to add one in the header:
HX711() {} // default constructor, empty

Add member function to do the init job (done by original constructor), also in the header file
    void Init(byte dout, byte pd_sck, byte gain = 128) {
    PD_SCK  = pd_sck;
    DOUT    = dout;

    pinMode(PD_SCK, OUTPUT);
    pinMode(DOUT, INPUT);

    set_gain(gain);
}

Now your ScaleMeasure class will be like (header):
class ScaleMeasure
{
 public:
    ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID); 
    void Setup();   
    float Measure();    

private:
    int _dout_pin;
    int _clk_pin;
    float _calibration_factor;
    byte _scaleID;
    HX711 _scale;  
};

and cpp
ScaleMeasure::ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID)
{
    _clk_pin = Clk;
    _dout_pin = Dout;

    _scale.Init(_dout_pin, _clk_pin);  

    _calibration_factor = CalibF;
    _scaleID = ScaleID;     
}


user84: The right way, in C++, to properly construct a field member b (of type class B) inside a class A is to do it as follows in A's constructor:
A::A() : b(...) {
    // Other init code here
}

In your situation that would mean:
class ScaleMeasure
{
 public:
    ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID); 
    void Setup();   
    float Measure();    

private:
    int _dout_pin;
    int _clk_pin;
    float _calibration_factor;
    byte _scaleID;
    HX711 _scale;  
};

Note that I have removed the init part for _scale.
ScaleMeasure::ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID)
: _scale(Dout, CLk)
{
    _clk_pin = Clk;
    _dout_pin = Dout;   
    _calibration_factor = CalibF;
    _scaleID = ScaleID;     
}


21020: <p>I am far from being an Arduino specialist, so please bear with me if some of my code below is far from correct.</p>

<p>I am writing a sketch in which I need to use 3 instances of the <a href="https://github.com/bogde/HX711" rel="nofollow">HX711 library</a>, as I am using 3 different weight sensors.</p>

<p>In order to try to clean up the code, I want to put basically all the code using HX711 in my own class.</p>

<p>Here is what my ScaleMeasure.h looks like:</p>

<pre><code>// ScaleMeasure.h
#ifndef _SCALEMEASURE_h
#define _SCALEMEASURE_h

#if defined(ARDUINO) &amp;&amp; ARDUINO &gt;= 100
    #include "arduino.h"
#else
    #include "WProgram.h"
#endif

#include &lt;CmdMessenger.h&gt;
#include "HX711.h"

class ScaleMeasure
{
 public:
    ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID); 
    void Setup();   
    float Measure();    

private:
    int _dout_pin;
    int _clk_pin;
    float _calibration_factor;
    byte _scaleID;
    HX711 _scale = HX711(_dout_pin, _clk_pin);  
};
</code></pre>

<p>and .cpp</p>

<pre><code>#include "ScaleMeasure.h"

ScaleMeasure::ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID)
{
    _clk_pin = Clk;
    _dout_pin = Dout;   
    _calibration_factor = CalibF;
    _scaleID = ScaleID;     
}

void ScaleMeasure::Setup()
{       
    _scale.power_up();
    _scale.set_scale();
    _scale.set_scale(_calibration_factor);
    _scale.tare();
    _scale.read();
}

float ScaleMeasure::Measure()
{   
    return _scale.get_units(5);
}
</code></pre>

<p>but there is obviously something wrong, as a call to the constructor lock the rest of the program. I believe that my instantiation, of HX711 in ScaleMeasure.h  <code>HX711 _scale = HX711(_dout_pin, _clk_pin);</code> is not correct, or not in the right place. The code compile fine, though.</p>

<p>Thanks for your help.</p>
 13594: <p>Unfortunatly HX711 has no default constructor. So the easiest way would be to add one in the header:</p>

<pre><code>HX711() {} // default constructor, empty
</code></pre>

<p>Add member function to do the init job (done by original constructor), also in the header file</p>

<pre><code>    void Init(byte dout, byte pd_sck, byte gain = 128) {
    PD_SCK  = pd_sck;
    DOUT    = dout;

    pinMode(PD_SCK, OUTPUT);
    pinMode(DOUT, INPUT);

    set_gain(gain);
}
</code></pre>

<p>Now your ScaleMeasure class will be like (header):</p>

<pre><code>class ScaleMeasure
{
 public:
    ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID); 
    void Setup();   
    float Measure();    

private:
    int _dout_pin;
    int _clk_pin;
    float _calibration_factor;
    byte _scaleID;
    HX711 _scale;  
};
</code></pre>

<p>and cpp</p>

<pre><code>ScaleMeasure::ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID)
{
    _clk_pin = Clk;
    _dout_pin = Dout;

    _scale.Init(_dout_pin, _clk_pin);  

    _calibration_factor = CalibF;
    _scaleID = ScaleID;     
}
</code></pre>
 84: <p>The right way, in C++, to properly construct a field member <code>b</code> (of type class <code>B</code>) inside a class <code>A</code> is to do it as follows in <code>A</code>'s constructor:</p>

<pre><code>A::A() : b(...) {
    // Other init code here
}
</code></pre>

<p>In your situation that would mean:</p>

<pre><code>class ScaleMeasure
{
 public:
    ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID); 
    void Setup();   
    float Measure();    

private:
    int _dout_pin;
    int _clk_pin;
    float _calibration_factor;
    byte _scaleID;
    HX711 _scale;  
};
</code></pre>

<p>Note that I have removed the init part for <code>_scale</code>.</p>

<pre><code>ScaleMeasure::ScaleMeasure(int Dout, int Clk, float CalibF, int ScaleID)
: _scale(Dout, CLk)
{
    _clk_pin = Clk;
    _dout_pin = Dout;   
    _calibration_factor = CalibF;
    _scaleID = ScaleID;     
}
</code></pre>
