Multiple MAX31855 reads problem

I have read multiple MAX31855 and I have tried with a "for" to optimize the code.
The code is shown below:

First I declared the 2 MAX31855

Adafruit_MAX31855 thermocouple1(MAXCLK, MAXCS1, MAXDO);
Adafruit_MAX31855 thermocouple2(MAXCLK, MAXCS2, MAXDO);

Furthermore, I tried this

for (int y = 1; y =2;y++)
{
String termopar="thermocouple"+String(y);
double c = termopar.readCelsius();
if (isnan(c)) {
Serial.println("Something wrong with thermocouple!");
dataString +="error ";
} else {
//Serial.print("C = ");
// Serial.println(c);
dataString += String(c)+" ";
}

delay(1000);

But I obtained error because the program read termopar as a string variable not as a thermocuple(y) variable.

'class String' has no member named 'readCelsius'

I'd be glad if anyone could help me.

Thanks

Variables have names at compile time. They do NOT have names at run time. They have memory addresses at run time. You haven't a hope in hell of making that code work.

What you need to do is put the objects in an array, and use the for loop to iterate over the elements of the array.

Adafruit_MAX31855 thermocouples[] = { Adafruit_MAX31855(MAXCLK, MAXCS1, MAXDO), 
Adafruit_MAX31855(MAXCLK, MAXCS2, MAXDO) };

Thanks!!

for (int y = 1; y =2;y++) <<<< ERROR

the y=2 part is an assignment , no comparison

-> syntax is OK as it compiles, semantics NOT (in most cases)