Use initializing list like this: (Best approach)
class Rachunek{
public:
Osoba& wlasciciel;
double stan_konta;
Rachunek(Osoba* wlasciciel, double stan_konta):
wlasciciel(*wlasciciel) ,
stan_konta(stan_konta) { //Uninitialized reference member
}
};
You have a reference as a member and a reference must be initialized right away. This notation allows for initialization at declaration time. If you instead used a normal member without &
it would work fine as you did it. Though the presented style here is more efficient.
Alternativly: (Lesser efficient approach)
class Rachunek{
public:
Osoba wlasciciel; // Note missing & on the type.
double stan_konta;
Rachunek(Osoba* wlasciciel, double stan_konta)
{
this->wlasciciel = *wlasciciel;
this->stan_konta = stan_konta;
}
};