How to set a variable's value in one class, while having the value updated in another
Hi all, I've got a certain instance in my program where an integer variable, let's call it 'x', is initialised in one part of a class, however the value is not present when the integer is called in another class.
To explain further, I've got 2 classes - 'class1' and 'class2'. The variable is declared in 'class1' as 'x'. At some point in class1, I give 'x' a value, let's say 5.
Now, when I create an object of 'class1' in 'class2', 'x' is automatically equal to 0. Why is it that after running class1, and then linking to class2, the value of 5 is not carried over onto the 'x' object in class2?
I'm sorry if it's a bit confusing, I'll try to explain differently if it's not understandable. Basically I want to know how one can update values of a variable in one class, and have those values updated in another class when you call it (obviously while initialising it during run time).