Proper Way to Create Array of Hardware Objects

Hello,

I'm new to Arduino and haven't used C++ in 20 years (lots of python and web languages since).

I'm trying to create arrays of various hardware objects and believe I'm hitting some syntax issues that I'm hoping someone can point me in the right direction.

I'm using this button library: Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.

If I create an array of buttons above the setup() function like this it works fine:

Button betButtons[] = {
Button(2,BUTTON_PULLUP_INTERNAL, true, 50),
Button(3,BUTTON_PULLUP_INTERNAL, true, 50)
}

That seems inefficient so I want to use a for() loop to create these so I try:

Button betButtons[10]; //define empty array of type:Button
//Load the Array
for(int i=0;i<10;i++) {
betButtons = Button(i+2,BUTTON_PULLUP_INTERNAL, true, 50);
}
Logic seems right but it errors saying no matching function for call to 'Button::Button()' on the Button betButtons[10] line.
I've been reading for the past hour on this and it seems there are a couple issues:
1. You can't do for loops outside the setup() and loop() or some other function so I try to define array at the top and put for loop inside setup() function but no dice.
2. Arrays / Pointers C++ stuff that I don't know about
This seems like super-basic functionality but I have not been able to find an example of how to build arrays of hardware class elements.
At the end of the day I want to be able to access buttons (or other things for that matter) using:
dosomething(betButtons[2]);
Any help would be appreciated or links to the concept I'm missing here.
Thanks,
Andy

You instantiate your objects at compile time.
for() is a runtime statement.

.

So there's no way to instantiate things using a loop?

No

What’s wrong with using copy and paste then change the pin number?.
Just use:
Button betButtons[] = {
Button(2,BUTTON_PULLUP_INTERNAL, true, 50),
Button(3,BUTTON_PULLUP_INTERNAL, true, 50),
Button(4,BUTTON_PULLUP_INTERNAL, true, 50),
Button(5,BUTTON_PULLUP_INTERNAL, true, 50),
Button(6,BUTTON_PULLUP_INTERNAL, true, 50)

}

So there's no way to instantiate things using a loop?

You should be able to create new objects in a loop using new, but you may need to declare the array of objects as an array of pointers to the objects. you could use new[] if there were nbo parameters to your object creation.