Custom Classes

Ok so I want to make a couple classes that draw shapes, text, and buttons on a tft screen using the gfx and ILI9341 libraries. My classes are used to store the size and positions of the shapes, and also to draw them on the screen. For instance

Rectange(int _x, int _y, int _length,int _width){
 width = _width;
}

My question is how to I give each shape's class access to a single tft object, without each class passing the object in?
Say I define the tft as Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS,TFT_DC);
How can Rectagle have a method that does tft.drawRect(x,y,length,width,color)

My question is how to I give each shape's class access to a single tft object, without each class passing the object in?

You don't. The class ONLY knows about what you tell it.

void Rectangle(Adafruit_ILI9341 &tft, int x, int y, int l, int w);

Adafruit_ILI9341 tft;
int mX, mY, mL, mW;

Rectangle::Rectangle(Adafruit_ILI9341 &theTFT, int x, int y, int l, int w) : tft(theTFT)
{
   mX = x;
   mY = y;
   // etc.

   tft.drawRect(mX, mY, ...
}

Ok thanks, i thought that I might have to do it that way, but wasn’t sure