Creating an instance of Progress Bar : "no default constructor available"

Hello, this is a very beginner level question but I am pretty lost here… I am looking to just create an instance of the Progress Bar, have it appear in my component and react to a variable.

The part I am lost on is that my compiler gives the error:

" juce::ProgressBar’: no appropriate default constructor available "

Can anyone just give me a basic rundown of how I would create one of these instances, and include what I have to pass into this object? I am assuming its a reference to a variable (double as its listed in the docs) but I am lost as to how I would actually write this in my editor… thanks!

You need to add a double type parameter in your editor class and pass that into the ProgressBar constructor. Note that the double member should be before the ProgressBar member in the class members to avoid a compiler warning and possible runtime errors.

class MyComponent : public Component
  MyComponent() : m_progressbar(m_progress)
    // your constructor body with addAndMakeVisible(m_progressbar); etc
  double m_progress = 0.0;
  ProgressBar m_progressbar;

You can initialize member variables without default constructors like this, without using the member initializer list:

    double m;
    T t{m}; //assumes T(double) is the only ctor

:warning: if you don’t provide a default constructor, m is very likely to be uninitialized.

So I guess it should be:

    double m = 42.0;
    T t{m};

Whoops, forgot that bit! No uninitialized variables!