function as function argument

Hello, currently i have two function who does just the same except that one uses Serial.print while the other, client.print. is there a mean to have just one function (w/o 'if')? How?

Thank for you time

You could pass a reference to the desired Print object into the function. AKA, take advantage of Polymorphism.

Thanks, i may be saying nonsense but, won't it generate 'if's ? I was thinking rather of the caller sending the calee a pointer the required function

I was thinking rather of the caller sending the calee a pointer the required function

...or a reference?

I have a feeling that your thinking about this is backwards. Post a simple code illustrating what you're trying to accomplish (or avoid).

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.