If you put the public: outside of a class than it will result in an error, public: is how you define if a portion of the class is public when used in conjunction with private: or protected:
public: will result in variables underneath it being public to other classes
private: will result in variables underneath it being only usable whether reading or writing by the class they are contained in
protected: will result in variables underneath it being only usable by the class itself or classes derived from the initial class
As for your question on how to use variables that are local to other functions, you can’t use local variables in other functions, however if your class were to contain the x_size, y_size, z_size variables inside it, you would be able to assign values to them inside of permanent_var_value() and use them in later functions.
In here, you should declare (ie. tell that it exists) the variables in the .h and initialise (give an initial value to the variable) in the .cpp. It is also possible to initialise variables in .h, but you shouldn’t do that, because it might lead to multiple instances of that variable existing (or so big boys have told me).
So in the .h below GENERATED_BODY() you would write for example (also shown here is the proper way to declare it public):
Initialising is done in the .cpp constructor, which would be the first “function” in your .cpp after the includes. Like this:
This variable can now be used in any of the functions and also it’s value can be changed. However, what I believe you want to do is to use the values used in permanent_var_value(). In this case you would declare three different variables in .h, as shown above - you can name them whatever, like newvar1, newvar2, newvar3 for example. It is suggested you use names that actually mean something so you know later what they are. After you have declared them, you also need to initialise them in the constructor as shown above. Then you would assign the values you want to use for them in the permanent_var_value function, like so:
In general, variables that are declared in a function can not be used in other functions.
Also to note: The size_x you see in the permanent_var_value function is not actually a declared variable, but a function parameter. This means the value comes from somewhere when the function is called. With the code above every time permanent_var_value function is called, it stores the values in your parameters. With only this one class to work with, it’s difficult to say when the permanent_var_value function is actually called so it’s impossible to say when/if you are getting your variables set. You need to find out what function calls it (in visual studio this is easy, as you can highlight and right click and all kinds of tools sprung up) and what variables it uses to call it. If it isn’t called, you will be always using your default values with those other functions.