if I have a class with a header and .cpp file, and in the .cpp file there is a variable declared outside of the functions, is that considered a global/shared variable if I have multiple instances of the class?
I understand that static variables are shared by all objects, but that is actually not what I want. I'm using those 'global' variables in the .cpp file because of some compiling confusion when making those variables private and wondering if this would be the source of some runtime issues. Thank you.
Yes. If a variable is declared outside any function or class and isn't marked 'static' it is a global. You can access it from any other .ino or .cpp file by declaring it as 'extern':
extern unsigned long MyGlobalVariable;
This tells the compiler what type of variable it is and that the linker will fill in the address when the definition is found.
You can get a similar but more controlled effect by putting the variable inside the class declaration and declaring it 'static'. It will be part of the class but all instances of the class will share the same variable. If in a "public:" part of the class it will be reachble by any .ino or .cpp that includes the class:
// In your MyClass.h:
public:
static unsigned long MyStaticMember;
// In your MyClass.cpp
unsigned long MyClass::MyStaticMemeber = 0;
// In your .ino or other .cpp:
#include "MyClass.h"
MyClass::MyStaticMemeber = millis();
Since the purpose of a class is encapsulation (hiding implementation details from users of the class) a 'static member variable' is generally a better solution than a global. Even better encapsulation would be to make the variable private to the class so nobody can change the variable without calling a class member function to do it.