Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check a function was called by another function?

I am currently trying to make sure that a member function of one class is only called by a member function of another class.

The architecture is imposed and cannot be changed, the port means that some logic has to be done in a.call() before calling b.call(). a.call() therefore calls b.call() to simplify things and make sure the order is respected.

I found this answer to my question. Only, the problem is that I am using classes, and the two classes have the same member function name and so the #define tries to replace all the occurrences which have different prototypes.

like image 260
3nixios Avatar asked Jun 13 '26 12:06

3nixios


1 Answers

I recommend the passkey pattern. It's very good for giving fine grained control on who can do what with your function.

like image 94
Xeo Avatar answered Jun 15 '26 01:06

Xeo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!