I'm new to C++ and a bit confused on how to use public variables.
I create a class:
class board{
public:
int n = 0;
};
Then I manipulate it in main:
int main() {
board xy;
xy.n = 10;
cout << anotherFunction();
return 0;
}
It would seem that only in main does n = 10; What I want to do is update it in the class so another function can use it. Is that possible? And if so how can I accomplish that?
int anotherFunction(){
board xy;
return xy.n; //need it to equal 10 now not 0 sense main updated it
}
Hope this makes sense. Thanks.