Class Object as Variable

Hi everyone,
this is my first post so I hope I follow all Forum rules correctly!

I have a code where I need to find the minimum and maximum of a Circular Buffer. I use the CircularBuffer lib
here is a part of my code:

 #include <CircularBuffer.h>
 
 CircularBuffer<float, 100> pressureBuffer;
 CircularBuffer<float, 100> temperatureBuffer;
 CircularBuffer<float, 100> humidityBuffer;
 
 for (int i = 0; i <= pressureBuffer.size(); i++)
 {
   if (pressureBuffer[i] > max)
   {
     max = pressureBuffer[i] + 5;
   }
   if (pressureBuffer[i] < min)
   {
     min = pressureBuffer[i] - 5;
   }
 }

as you see I have three CircularBuffer variables. Now my question is: how can I use the CB variable for a function? something like

 int findMin(anyBuffer)
 {
   for (int i = 0; i <= anyBuffer.size(); i++)
   {
     if (anyBuffer[i] < min)
     {
       min = anyBuffer[i] - 5;
     }
   }
  return min;
 }

thx in advance!

Why "<=" ?

Welcome

And you can do something like this : int findMin( CircularBuffer<float, 100> const &anyBuffer )

That was just a Typo I think. Of course it should be "<". Thanks for the correction!

Thank you very much. That worked as expected. I did not know that I had to refer to the class again in the function argument and tried to handle it like a "normal" variable. One question: Why would you use const in this context?

Because your findMin() function doesn't need to modify data in the buffer.

Typos are usually one-offs.

Yeah I don't know what happended there. I think I copied it from the example of CircularBuffer. Yet in the example it is < not <=. No clue. But thanks again for correcting!

Does that have any advantage for the program or just for me that I don't modify the Buffer by mistake?