Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11631

Is there a type of parameter that can (efficiently) accept one or multiple variables depending on usecase?

$
0
0

I want to make a helper function that can take 1 or more floats depending on the context in which it's being used. Pseudo version shown here:

void processData(float data) {  //stuff}

where I could call the function for a single variable or an array if needs be

float x = ...;processData(x);//orfloat x[3] = {..., ..., ...}processData(x);

Sorry if this is poorly communicated, I'm not entirely sure what I'm looking for so giving specifics is kinda hard.

I've looked into using straight arrays, feels kinda goofy and innefficient to cast to every instance where a single variable is being passed to an array.


Viewing all articles
Browse latest Browse all 11631

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>