0

I would like to know the best approach to check in a method, which object has called it. For instance:

class a
class b
class utility c (c has a method x())

How can I know inside x method wich class, a or b, called it?

thanks

Jonio
  • 1,213
  • 2
  • 15
  • 35
  • 2
    Not that it should really matter except for debug information. Code shouldn't behave differently depending on *who called it.* – deceze Sep 14 '18 at 11:40
  • If class `c` needs to know information about the caller, consider passing it in as an argument instead – iainn Sep 14 '18 at 11:40
  • I want avoid to pass an arguments in the method. Thanks – Jonio Sep 14 '18 at 11:46
  • Depending on what that argument does, you *should* probably really pass it explicitly. – deceze Sep 14 '18 at 11:47

0 Answers0