I am learning C ++ and moving my project from C to C ++. In this process, I came across this problem: how to save / update variables that are used in several classes? In C, I used global variables, but this is not good for C ++.
So, suppose we have 4 classes:
class Main_Window
{
void load_data_menu_selected();
}
class Data
{
double *data;
}
class Load_Data
{
double *get_filename_and_load();
}
class Calculate
{
int do_calculation()
}
So, Main_Window is the class for the main application window, where it interacts with user input, etc.
I want to do:
create an instance of the Data class in Main_Window use Load_Data to load data from a file and save it to Data li> use the calculation class to do something with the read data in the data class: , Data . ?