Suppose I have a simple console program as follows:
(haven't tested it and it may contain errors since I'm sort of a newbie)
#include <iostream>
using namespace std;
void startProgram();
int main(){
a = 20; //I want to somehow set this so that I can use it in any other function
//without passing it through like startProgram(a);
startProgram();
return 0;
}
void startProgram(){
cout << a << endl;
}
So... How do I make it so that I can change the value of 'a' or print it or do whatever without passing it through to every function?
And sorry if there are questions like this already, which I don't doubt, but I couldn't find any!
Thanks in advance!