I have the following 2 functions:
void B::set(A * ptr){ this->a = ptr; this->info = get_some_info_from_a(*ptr); } T get_some_info_from_a(A& ref){ return ref.info; } As you see, I have A * ptr as a pointer in set(...), but I would need a reference to call get_some_info_from_a(...). So I dereference ptr and give it as an argument.
Is that correct? Is it efficient given A has some resources which must be copied by a copy/move constructor? I ask the question because it really seems that this line introduces some mysterious bugs.
get_some_info_from_anever accesses therefargument, but returns a global variable namedinfo. Is that what it's supposed to do?infofromref.