I want bi to be changed each time ai changes ,possibly using
references.Can anyone help me : bellow is the code - please suggest
changes -
#include<iostream>
using namespace std;
class B
{
private:
int bi;
public:
B()
{
bi=10;
}
int& get_bi()
{
return bi;
}
void display()
{
cout<<"bi = "<<bi<<endl;
}
};
class A
{
private:
B b;
int ai;
public:
A()
{
ai=b.get_bi();
}
void assign(int i)
{
ai=i;
}
void display()
{
cout<<"ai = "<<ai<<endl;
}
};
int main()
{
B bo;
bo.display();
A ao;
ao.display();
ao.assign(1111);
ao.display();
bo.display();
return 0;
}