class tijelo {
friendvoid pomoc (tijelo* ptrObj, bool tijelo::*ptrClan);
public:
tijelo () : Srce (newbool (true)), LijeviBubreg (newbool (false)), DesniBubreg (newbool (false)),
Jetra (newbool (true)), Slezena (newbool (false)) {}
tijelo (const tijelo& reftijelo) : Slezena (reftijelo.Slezena), DesniBubreg (reftijelo.DesniBubreg), LijeviBubreg (reftijelo.LijeviBubreg),
Jetra (reftijelo.Jetra), Srce (reftijelo.Srce) {}
~tijelo () {
delete Srce;
delete DesniBubreg;
delete LijeviBubreg;
delete Jetra;
delete Slezena;
}
private:
bool* Srce;
bool* LijeviBubreg;
bool* DesniBubreg;
bool* Jetra;
bool* Slezena;
};
void pomoc (tijelo* ptrObj, bool tijelo::*ptrClan);
int main () {
tijelo ja;
tijelo *ptrtijelo = &ja;
pomoc (ptrtijelo, &ja.DesniBubreg); //can't access private member!
system ("pause");
return 0;
}
//this funct. will test if member has true and then set to false if false do nothing
void pomoc (tijelo* ptrObj, bool tijelo::*ptrClan) {
if (ptrObj->*ptrClan == false)
cout << "member is not true!" << endl;
else {
ptrObj->*ptrClan = true;
cout << "member seted to true" << endl;
}
}
members must be private (so no class changes are allowed in this example-- only function)
I must solve how to make function work.. to acces members and change them.