C++ access class private attribute friend funcion with (void * callerobj) parameter -
i have class called sender private attribute issending , friend function sending. inside friend function, want access issending attribute
class sender{ private: issending=false; friend void* sending (void * callerobj); } void* sending (void * callerobj){ while(<issending true>){ } } i've tried
callerobj->issending callerobj.issending but got compile error. how can access issending friend function (void * callerobj) parameter?
since type of callerobj void*, cannot use access member data or member function. after all, original object int*.
if sure original object sender*, can cast callerobj sender* , use access member data.
sender* senderobj = reinterpret_cast<sender*>(callerobj); if ( senderobj != nullptr ) { while ( senderobj->issending ) { ... } }
Comments
Post a Comment