Iterate over several instances of one library possible?(MCP23017 short detection

Hi
I am trying to detect short circuits between groups of (eg) capacitors which are all connected to one pin each of a MCP23017 multiplexer port A on the one side and to gnd on the other side (8 per multiplexer).
(Port B is used for a different part of the circuit)
In order to do this, I switch all pins of port A to input with input pull ups enabled, then iterate over the pins. I switch one after the other to output/GND and then check whether any other pin went low.
If so, there has to be a short and I need to examine the DUT.
As I need to do this for circuits with more than eight capacitors, I am using more than one port multiplexers.

I am wondering if there is a way to initiate the libraries differently from

#define MCP23017_0_ADDR 0x20
#define MCP23017_1_ADDR 0x21
MCP23017 mcp0 = MCP23017(MCP23017_0_ADDR);
MCP23017 mcp1 = MCP23017(MCP23017_1_ADDR);

eg in an array so I can iterate over the port expanders?
I know that in python I could iterate over a list (for elements in mcp0 mcp1…) but I am wondering if there is something similar in C, or do I need to explicitely write the code for each port expander?

Some (a bit better than) pseudocode of what I am trying to accomplish:

for (uint8_t mcpX = 0; mcpX < numMCP; mcpX++) {
  mcp[mcpX].portMode(MCP23017Port::A, 0b11111111); //Port A as input
  mcp[mcpX].writeRegister(MCP23017Register::GPPU_A, 0xFF, 0xFF);  //pins, pullup or nothing
  }
}
for (uint8_t mcpX = 0; mcpX < numMCP; mcpX++) {
 for (uint8_t pins=0; pins<8;pins++)
 mcp[mcpX].pinMode(pins,OUTPUT);
 mcp[mcpX].digitalWrite(pins,LOW);
 val= mcp[mcpX].readRegister(MCP23017Register::GPPU);
 if(val ^ (1 << pins){
   Serial.println("Error, short circuit detected on Multiplexer ");
   Serial.print(mcpX);
   Serial.print(" Pin ");
   Serial.println(pins);
}

Thank you very much for any hints.
P.S: I am using the MCP23017 library GitHub - blemasle/arduino-mcp23017: Complete support of MCP23017 as the newer editions of the adafruit library don’t seem to support more than one multiplexer. (or instances of the library being called)

I think:

MCP23017 mcp[2] = {
  MCP23017(MCP23017_0_ADDR),
  MCP23017(MCP23017_1_ADDR)
};

PaulRB:
I think:

MCP23017 mcp[2] = {

MCP23017(MCP23017_0_ADDR),
 MCP23017(MCP23017_1_ADDR)
};

Hi Paul
Thank you very much, it’s working perfectly now.
for (uint8_t mcpX = 0; mcpX < numMCP; mcpX++) {
mcp[mcpX].init();
}
Best regards