First of all, in the instruction it is said that the function working with pointers should be called
setRandomByPointer
. By doing so, it might help you know which function is called.
But as mentioned in solution 1, it would be possible to have both functions having the same name and the compiler would be able to figure out which one to call.
Then it seems that you have not properly done some steps or not doing them in order... It also seems to depends on a previous homework. And some stuff seems to come from nowhere...
As a side note, normally a non static member function would operate on its own rectangle.
And by the way, if we compare your 2 functions, we can see that the first one operate on the argument (
r
):
r.min.x = pos_x - width;
...
while the second one operate on the object itself (
this
) :
this->min.x = posX - widthPoint;
...
In your homework, you need to work on the argument as specified in the instruction. In real world, no one would do that as it is the most confusing way to do that (you call the function on one instance but update the one passed in argument).