I'm trying to create a dummy function inside of a class, whichs' body will be changed later in int main()
. And then I'd like to call this body changed func in the class. Is there a way to achieve this?
Something like this:
class Animation {
public:
//Don't know what to write at the next line
function<void>/*?*/ whenCompleted = []() mutable { /* Dummy func. */ };
.
.
.
void startAnimation() { /* Do stuff, then */ animationEnded(); }
void animationEnded() { whenCompleted(); }
}score;
int main(){
score.whenCompleted = { /* new body for whenCompleted() */ }
score.startAnimation();
}
Aucun commentaire:
Enregistrer un commentaire