Pointer to specific instance of class/object in an array

Please correct me if I’m using the incorrect lingo,

I have an array of custom objects and I need to access a method in one of the objects. Now, while I can access it via it’s array index, I’d like to use a friendly name so my code is more readable. Can I create a pointer to that specific object and what’s the best way to do so without using too much more RAM?

class PressureSensor{
  public:
    PressureSensor(int _startingValue){
      value = _startingValue;
    }
    void getValue(){
      return value;
    }
    void setValue(int _value){
      value = _value;
    }
  private:
    int value;
};

PressureSensor pSensors[3] = {
  PressureSensor(50),
  PressureSensor(100),
  PressureSensor(150),
};

Instead of using

pSensors[1].getValue();

I’d like to use

highPressure.getValue();

Where do you define your variable 'highPressure'?

highPressure is supposed to be a pointer to pSensors[1]. I don’t know where/how I should define it.

First, you have to fix this:

   void getValue(){
      return value;
    }

You claim that getValue() returns no value (that's what 'void' means), then you try to return a value.

Then something like:

  PressureSensor *highPressure = pSensors + 1;
  int p = highPressure->getValue();

Thanks!

This is what I've been trying to figure out.

PressureSensor *highPressure = pSensors + 1;

m_elias:
Thanks!

This is what I’ve been trying to figure out.

PressureSensor *highPressure = pSensors + 1;

Or you could do as real programmers do:

  PressureSensor *pSensor = pSensors[1];

PaulS:
Or you could do as real programmers do:

  PressureSensor *pSensor = pSensors[1];

Perhaps real programmers who don't know how to use pointers. That should be:

PressureSensor *pSensor = &pSensors[1];

gfvalvo:
Perhaps real programmers who don't know how to use pointers. That should be:

PressureSensor *pSensor = &pSensors[1];

My bad for assuming that everyone followed my naming convention of using a lower case p in the name of all variables that are pointers or arrays of pointers. I see now that pSensors is not an array of pointers, so the address of operator is indeed required.