How can I make a variable global from another source file

Nov 14, 2015 at 9:19am
Hello, how can I make a variable global like for example i have a variable int num =1, it is in numbers.cpp , but I want to transfer it or make it global to main.cpp .. Is this possible,if it is, can someone somehow give an example or help me do it? Thanks in advance.

Nov 14, 2015 at 9:40am
Nov 14, 2015 at 1:59pm
In main.cpp, add (in a global scope, somewhere near the top of the file):

extern int num;
Topic archived. No new replies allowed.