If you want a "global method access" then the object has also to be a global variable. Making it a local variable always return the initialization value!
#include <iostream>
class A
{
private:
int a; // keep the variable private, otherwise you wouldn't need the "get_a" function!
public:
int get_a()
{
return a;
}
};
A a ; // the global object.
void access_get_a()
{
int temp = a.get_a(); // here we access the global object
}
void main()
{
access_get_a() ;
};
Although this should compile, this is most likely not the best solution.
But to find a better one, I need more information ;-).