Reputation: 807
Lets suppose i have a class A which implements this function:
function do_Some_Thing_With_Points(obj, P)
obj.other_function();
I would like to understand the following use of this function:
Let a be an instance of A and:
a.do_Some_Thing_With_Points(P);
Is it ok to not pass the parameter obj
, and what does it mean?
Thanks!
Upvotes: 0
Views: 60
Reputation: 1320
You are actually passing obj
, which is in your case a
. This is because this
a.do_Some_Thing_With_Points(b);
is equivalent to
do_Some_Thing_With_Points(a, b);
at least if only one instance of the class is provided to the function.
The syntax of the second case is not recommended, since the 'owner' of the method is not provided explicitly (if b would be an instance of class A as well, this method owner is not obvious). I just included it to help you understand where the obj
comes from.
Upvotes: 2