I have a variable that I would like to use in all my classes without needing to pass it to the class constructor every time I would like to use it. How would I accomplish th
Just declare it outside the class:
Header file:
extern int x; class A { int z; public: A() : z(x++) {} };
One source file:
int x = 0;