As it was said in other answers, there's no such a thing as a special syntax for accessing local variables externally, but you can achieve this by returning a reference to the variable, for instance:
#include <iostream>
using namespace std;
int& f(void)
{
static int count = 3;
cout << count << endl;
return count;
}
int main()
{
int &count = f(); // prints 3
count = 5;
f(); // prints 5
return 0;
}
In C++11 you can also access your local static variables from a returned lambda:
#include <iostream>
#include <functional>
using namespace std;
std::function<void()> fl()
{
static int count = 3;
cout << count << endl;
return []{count=5;};
}
int main()
{
auto l = fl(); // prints 3
l();
fl(); // prints 5
return 0;
}