How to limit the accessibility of a variable to only the current source file in C++

1 Answer

0 votes
#include <iostream>

// Visible only within this source file
static int sGlobal;

int main()
{
    sGlobal = 7;
    
    std::cout << sGlobal;
}



/*
run:

7

*/

 



answered Dec 1, 2022 by avibootz

Related questions

2 answers 200 views
1 answer 148 views
1 answer 116 views
1 answer 150 views
1 answer 129 views
...