Is there a way to use functions defined in a library in any class? I'm trying to design a menu interface on a 1.8'' TFT display module. I've got it working with the Adafruit_ST7735 + Adafruit_GFX libraries. At least when I was just trying out the features... But now I'm trying to organize the code in Classes as this thing will get too complex soon. I have done some Java and C, so I started learning C++. I've been reading and coding nonstop for a week now, but there are some things that I can't wrap my head around that keep me from making any progress for a couple of days already.

So... For example there's a function public void drawRect(); in Adafruit_ST7735 library and I have a function draw() that draws a bunch of related stuff to the display in my own class (Rectangle.cpp). Say I initialize the display in my main program file how can I use that drawRect() function in my Rectangle::draw()?

Also Rectangle will be used for composing other parts of the menu interface and will probably be initialized in a collection or as a member of another class. 

I've tried a bunch of different things but I've come to a dead end.

EDIT:

main program:

#include "_v0_0_0.h"
#include &lt;Adafruit_GFX.h&gt;    // Core graphics library
#include &lt;Adafruit_ST7735.h&gt; // Hardware-specific library
#include &lt;SPI.h&gt;

#include "Point.h"
#include "Rectangle.h"
#include "SomeView.h"

#define     TFT_CS  4
#define     TFT_RST 0
#define     TFT_DC  10

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
SomeView a_view;

void setup()
{
    tft.initR(INITR_BLACKTAB); // initializes the display
}

void loop()
{
    a_view.draw(); //draw something to view (a button, scrollbar, menu item, etc)
    while (true) {}
}


SomeView.h:

#include "Rectangle.h"

class SomeView {
private:
    Rectangle a_rectangle;
public:
    SomeView();
    void draw();

    const Rectangle&amp; getRectangle() const {
        return a_rectangle;
    }

    void setRectangle(const Rectangle&amp; rectangle) {
        a_rectangle = rectangle;
    }
};


SomeView.cpp:

#include "SomeView.h"

SomeView::SomeView() :
        a_rectangle(Point::Point(0, 0), Point::Point(0, 0)) {
}

void SomeView::draw() {
    a_rectangle.setCorners(Point::Point(0, 0), Point::Point(2, 6));
    a_rectangle.draw();

    a_rectangle.setCorners(Point::Point(20, 66), Point::Point(100, 100));
    a_rectangle.draw();
}


Rectangle.h:

#include "Point.h"
#include &lt;Adafruit_GFX.h&gt;    // Core graphics library
#include &lt;Adafruit_ST7735.h&gt; // Hardware-specific library
#include &lt;SPI.h&gt;

class Rectangle{
private:
    Point p1;
    Point p2;
public:
    Rectangle();
    Rectangle(Point&amp; p1, Point&amp; p2);
    void setCorners(const Point&amp; p1, const Point&amp; p2);
    void draw();

    // ... getters and setters for the points
};


Rectangle.cpp:

#include "Rectangle.h"

Rectangle::Rectangle() : p1(), p2()
    {
    }

Rectangle::Rectangle(Point&amp; p1, Point&amp; p2) : p1(p1), p2(p2)
    {
    }

void Rectangle::setCorners(const Point&amp; p1, const Point&amp; p2) {
    this-&gt;p1 = p1;
    this-&gt;p2 = p2;
}

// this is where I want to use a function from the adafruit library
void Rectangle::draw() {
    Adafruit_ST7735::drawRect(p1.getX(), p1.getY(), p2.getX(), p2.getY(), ST7735_GREEN); 

}
Yes, there is a way.

However that's not how object oriented programming (OOP) is supposed to be used, at least in theory.

Most likely you won't like my advice, but here it is: take it easy, find a good book or online course and learn to program on a system that is simpler to debug, than a microcontroller.

Your PC, for example.

C is closer to the HW than java. C++ can be seen as both of them, but there is not so much you can do without learning C, properly.
From that perspective, C++ can be seen also as a superset of C, only much more complex.

Have a look at this explanation, for example.
It's quite simple, but exhaustive. Read it carefully and you will find out that pointers are not so difficult to grasp, after all.

If you spend enough time to get the basics right, it will save you lots of frustration (and, yes, time!) later on.

For a more systematic approach, try this.