Linking to C++ includes, or having a Dictionary or List template?

You can create a class that link a particular motor and speed value.

class motorWithSpeed
{
   int motorPin;
   int motorSpeed;

   motorWithSpeed(int pin);
   
   setSpeed(int speed);
   int getSpeed();
};

You can create an instance of that class:

motorWithSpeed speedy(3);

You can make that motor change speed:

speedy.setSpeed(160);

You can later determine how fast the motor is going:

int speedySpeed = speedy.getSpeed();

Only the class instance maintains the speed.