Hi!
I have a program that runs multiple apps. To do this, I switch out what loop function I'm running using an array of function references, as seen here:
void loopA(void){
//do some stuff
}
void loopB(void){
//do some other stuff
}
const void (*appLoops[2])()={&loopA,&loopB};
However, for very short functions, this is very impractical and uses a lot of space.
I'm wondering if you can do anonymous function declarations and store them directly during the array's initialization.
//This code is javascript, but is what I hope to achieve in C++:
var appLoops=[
function(){/*do some stuff*/},
function(){/*do some other stuff*/}
];
This may be impossible, but it sure would be handy if it were!
So is it?
Thanks!