This may be a stupid question, I’m a bit rusty on C++, but I’m looking at the source code for MidiDemo.h. There is a private variable for the two ListBoxes that display the MIDI Input and Output Lists.
std::unique_ptr<MidiDeviceListBox> midiInputSelector, midiOutputSelector;
The MidiDeviceListBox is declared as a struct, and not a class, inside the main Component:
struct MidiDeviceListBox : public ListBox,
MidiDeviceListBox (const String& name,
: ListBox (name, this),
If I recall, the only actual difference between struct and class is that in struct the default visibility of its members and functions is public, and in class it’s private. By convention, struct is generally used, though, when you don’t mind exposing the innards (member variables) to the owner/creator/container. Class is more often used to hide those internal details. Because the default visibility of struct is public, it is generally the type to use for POD (plain old data), where all you have is member data, not member pointers or functions that perform actions on internally hidden data. But that’s just a convention. If you explicitly specify the visibility of the members, and it’s not intended as a POD struct, then either one is fine to use. As for why the ROLI developer who wrote that code used struct there, I don’t know. But it doesn’t really matter.