adding an incremental value to the end of a variable

I'm not sure if that is the correct terminology, I am making a keypad lock that cycles through 10 pin numbers, once password1 has been used password2 is now the active code, when that is used password3 is the active code and so on.

The basic idea is to add an integer (i) to the end of password, when the correct pw is entered it ++i then the code will be looking for password(i) that will be say a 6 then next time i will = 7 so the code will look for password7.

I cant find a way to add the integer value i to the end of 'password' for the void check password method.

Code snippet

Password password =   Password ("123456");
Password password1 =  Password ("695847");
Password password2 =  Password ("176234");
Password password3 =  Password ("951086");
Password password4 =  Password ("986510");
Password password5 =  Password ("284396");
Password password6 =  Password ("084763");
Password password7 =  Password ("412763");
Password password8 =  Password ("407195");
Password password9 =  Password ("274069");
Password password10 = Password ("074859");


void checkPassword() {
   if (password(i).evaluate()){   // Check Pass Code from 0 to 10
          Serial.println(" OK.");  
          i ++;                // Add 1 every time the correct PW is used
          if (i == 10) i = 0;  // Reset i to 0 when all 10 codes are used
       } else {
      Serial.println(" Wrong passwowrd!");
   }

This is the problem
if (password(i).evaluate()){ // Check Pass Code from 0 to 10

I have tried password + (i) and a few other formats but no luck yet

Full code

#include <Keypad.h>
#include <Password.h>
 
 

String newPasswordString; //hold the new password
char newPassword[6]; //charater string of newPasswordString
 
//initialize password to 1234
//you can use password.set(newPassword) to overwrite it
Password password =   Password ("123456");
Password password1 =  Password ("695847");
Password password2 =  Password ("176234");
Password password3 =  Password ("951086");
Password password4 =  Password ("986510");
Password password5 =  Password ("284396");
Password password6 =  Password ("084763");
Password password7 =  Password ("412763");
Password password8 =  Password ("407195");
Password password9 =  Password ("274069");
Password password10 = Password ("074859");

 
byte maxPasswordLength = 6; 
byte currentPasswordLength = 0;
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Four columns
int i = 0;

//Define the keymap
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
 
//// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {6,7,8}; //connect to row pinouts
 
// Connect keypad COL0, COL1, COL2 and COL3 to these Arduino pins.
byte colPins[COLS] = {2,3,4,5}; //connect to column pinouts
 
// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
 
void setup(){
   Serial.begin(9600);
}
 
void loop(){
   char key = keypad.getKey();
   if (key != NO_KEY){
      delay(60); 
      switch (key){
      case 'A': break; 
      case 'B': break; 
      case 'C': break; 
      case 'D': changePassword(); break; 
      case '#': checkPassword(); break;
      case '*': resetPassword(); break;
      default: processNumberKey(key);
      }
   }
}
 
void processNumberKey(char key) {
   Serial.print(key);
   currentPasswordLength++;
   password.append(key);
   if (currentPasswordLength == maxPasswordLength) {
      checkPassword();
   } 
}

void checkPassword() {
   if (password(i).evaluate()){   // Check Pass Code from 0 to 10
          Serial.println(" OK.");  
          i ++;                // Add 1 every time the correct PW is used
          if (i == 10) i = 0;  // Reset i to 0 when all 10 codes are used
       } else {
      Serial.println(" Wrong passwowrd!");
   } 
   resetPassword();
}

void resetPassword() {
   password.reset(); 
   currentPasswordLength = 0; 
}

void changePassword() {
   newPasswordString = "123";
   newPasswordString.toCharArray(newPassword, newPasswordString.length()+1); //convert string to char array
password.set(newPassword);
   resetPassword();
   Serial.print("Password changed to ");
   Serial.println(newPasswordString);
}
 
//void resetPassword() {
   //do something to resetPassword
//}

any help is greatly appreciated!

Many thanks

I cant find a way to add the integer value i to the end of 'password' for the void check password method.

It wouldn't do any good, anyway. Names do not exist at run time. Only addresses do, and that is what would be stored in the array if you created an array of Password objects.

Thanks for the info, i'm barking up the wrong tree, I will try again with an array.