Garmaine Staff asked 1 year ago

I have a two class called associate and report which is declared in associate.h file and report.h file respectively. report class inherits associate class in report.h as follows


class associate {
int num1, num2;


class report : public associate {
int add();

I have a main.cpp where I have included associate.h header and created object and intialized values for the same like below.

associate a{};
a.num1 = 10;
a.num2 = 20;

now I have one more cpp file called report.cpp where i have included report.h and associate.h and trying to access num1 and num2 values like

report r{};
cout << r.num1 << num2 << endl;

which is actually not printing 10 and 20 which I have set in main.cpp. How to access those values from another cpp file in this case from report.cpp?