how are arguments passed in reference to a function

I'm trying to modify a ns3 script.
calling of the function by its reference has left me confused

the function defination
1
2
3
4
5
6
7
8
9
.
.
void
RemainingEnergy (double oldValue, double remainingEnergy){
NS_LOG_UNCOND (Simulator::Now ().GetSeconds ()
                << "s Current remaining energy = " << remainingEnergy << "J");
}
.
.


and the function call
1
2
3
4
5
6
.
.
Ptr<BasicEnergySource> basicSourcePtr = DynamicCast<BasicEnergySource> (sources.Get (1));
basicSourcePtr->TraceConnectWithoutContext ("RemainingEnergy", MakeCallback (&RemainingEnergy));
.
.


I cant understand how the argument list is being passed.
Can someone explain it to me ?



the complete script https://www.nsnam.org/doxygen/energy-model-example_8cc_source.html
From what I can see, this isn't actually calling the function but rather setting the value of a function pointer. If you don't know what they are, function pointers are simply pointers to functions: You can assign functions to them and then call them, etc. These are normally used as callback functions, so the underlying API actually provides the parameters based on events that it recieves.
thanks
now it seems obvious
Topic archived. No new replies allowed.