I was doing my homework assignment and encountered a question which required us to return a value by reference. I got the question correct, but I'm not sure why. Can anyone care to explain me how this member function of a struct actually works. (or you could even direct me to a detailed resource).
The code for the member function is:
double& SafePtrToDouble::Dereference(){
  if((*this).d!=nullptr){ 
    return *((*this).d);
  }
  else{ throw std::logic_error("Error");}
}
Please tell if this description is a little vague. Thank you!
 
     
    