reference to static function variable

This is quite weird question but is it possible to have a reference or something to a static variable in global function?

like this way:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

#include <iostream>
#include <string>

using namespace std;

void test()
{
    static int tv;
    
    tv = 7;
    cout << "Test: " << tv << endl;
}

int main()
{
 test();
 cout << "Test 2: " << test::tv << endl; // Something like this?
}
No. But you can safely return a pointer or a reference to a static local variable.
@helios: saying 'no' and then 'yes' at the same time is confusing.

@cCj:
1
2
3
4
5
int &test()
{
    static int tv = 7;
    return tv;
}
Topic archived. No new replies allowed.