#include <iostream>
using namespace std;
int myInt = 6; //This is your global variable
int main()
{
cout << myInt;
return 0;
}
that is a basic global variable program. Using global variables are very dangerous though, as they are shared data that any other function can change the data to. Which in turn creates a bug that is very challenging to find.
No comments:
Post a Comment