Q:

How do I use variables that are in my main file (main.cpp) in other files (foo.h, foo.cpp)?

How do I use variables that are in my main file (main.cpp) in other files (foo.h, foo.cpp)?
No code is really necessary but I'll post some to help clarify my question.
main.cpp
#include<iostream>
#include<foo.h>

using namespace std;

int aa = 10;
int bb = 20;

Foo xyz;

int main() {
    cout<<"Hello World"<<endl;
    xyz.doSomething();
    return 0;
}

foo.h 
#ifndef FOO_H
#define FOO_H

class Foo
{
    public:
        void doSomething() {
            int abc = aa + bb;
            cout<<"aa + bb = "<<abc<<endl;
        };
};

#endif // FOO_H

A:

You should declare a main.h file, declare your variable there and declare it later in the main.cpp. So you would have
main.h
extern int aa, bb;

main.cpp
#include "main.h"
#include <iostream>
#include <foo.h>

using namespace std;

int aa = 10;
int bb = 20;

Foo xyz;

int main() {
    cout<<"Hello World"<<endl;
    xyz.doSomething();
    return 0;
}

Then you can just include main.h and use aa and bb

