I want to create a function like a for loop where I will ideally enter a variable for the times the iteration should happen and some functions inside brackets my function will execute. I hope I was clear enough.
Example
superFor (1) { // Commands to be executed here add(1 + 2); }
What you want isn’t possible in C++ because the (current version of the) language lacks some features that are required here: namely, creating function blocks “on the fly”.
The best you can do is pass a function pointer or function object to your function. The STL offers many examples of this. Consider:
This passes a pointer to function
outto the functionfor_each.