I think he wanted to run a program without having a long list of global variables that may be unnecessary.
A program may run 7/10 times without ever calling function two() thus the declaration of the global variable never had to happen.Code:
If this is your problem then why not use global pointers? Otherwise the post above this one with global declarations seems fine.
ex: global pointers.
Thus you have global variable declarations that are technically global variables, but aren't really created in memory until a desired function is called in your .lib file. Then you could just extern your pointers in the files that need access to them or include the .lib file that contains the pointer declarations. Would this work for you?Code:
int *variable1; // This is a global declaration.
double *variable2; // This is a global declaration.
variable1 = new int;
variable2 = new double;