How to make a function respond differently depending on who is calling it

For example, let there be a function called mark(int n, int m)
if human() calls mark, then mark returns m + n
if comp() calls mark, do m+=1 and n+=1 then return m + n

Something like
1
2
3
4
5
6
mark(int n, int m){
if(comp() called me){
m+=1; n+=1;
}
return m + n;
}
Last edited on
along with int n, and int m, you can send a third int that represents who called the function.

Let's say human's ID is 0, and comp's ID is 1.

human calls mark, something like this - human.mark(5,10, 0);

And inside the function you do 2 if statements, if the ID is 0, just return m + n. If it's 1, do m+=1 and n+=1 then return m+n.

Thanks a lot, TarikNaej!
Topic archived. No new replies allowed.