Label .... Question re the PIP tutorial


#1

I am just starting out using JUCE, having spent a bit of time with C++, and am enjoying working with the tutorials and using the PIP’s to get me going. I am currently looking at the Label tutorial and can see the declaration of the various labels at the end of the header file but there is no constructor anywhere that I can see for them? The documentation implies that to create a label I should use

Label::Label ( const String & componentName = String() ,
const String & labelText = String()
)

but in the PIP header all I can see is Label titleLabel(); i.e. no parameters are passed
and the label is set up in the MainContentComponent()

addAndMakeVisible (titleLabel);
titleLabel.setFont (Font (16.0f, Font::bold));
etc

So, is this the correct way to create a label in my future projects, or should I be using the label constructor?

Thanks
Mark


#2

What you can see in the documentation is the use of default values for function parameters. If you don’t provide these arguments they will default to an empty String. Which itself is constructed using String().
Quick search shows this page, explaining it good, I think: https://www.programiz.com/cpp-programming/default-argument


#3

Ah I see … many thanks :slight_smile: