How to have a global class instantiated

My program starts on main.cpp, that creates the main window, etc.
I would want to have a global instance of MYCLASS, so if I wanted to use some function of it, I only would have to write MYCLASS.myfunction.
So , mmm , how can I have global variables and clases ? Where I have to write and how?
Thanks

you won't have MYCLASS.function(), this isn't java.
you can have either
1
2
3
4
5
6
7
8
9
10
11
12
struct CLASS{
   int var;
   void func(){}
};

CLASS global;

int main(){
   global.var = 5;
   global.f();
   return 0;
}
or
1
2
3
4
5
6
7
8
9
10
11
struct CLASS{
   static int var;
   static void func(){}
};
int CLASS::var;

int main(){
   CLASS::var = 5;
   CLASS::f();
   return 0;
}
Topic archived. No new replies allowed.