0

Need help c++

i have 3 function func_1 func_2 func_3 is it possible to call these functions using for loop eg for (i=1;i<=3;i++) func_i(); i think this is the wrong method btw if it's really wrong then how do i call these functions recursively

26th Jan 2018, 2:16 PM
‎ ‏‏‎Anonymous Guy
6 Answers
+ 10
Function pointers are the only thing I know of that can accomplish something similar to what you proposed. https://code.sololearn.com/c89HvBA8lLwu/?ref=app
26th Jan 2018, 3:04 PM
jay
jay - avatar
+ 4
I'm not sure if C/C++ has support for calling functions with strings, but you could just embed the loop within the function, and not have multiple functions. If you must have multiple functions, you can just call them from within the functions, if this requirement is met.
26th Jan 2018, 2:25 PM
eRosz
eRosz - avatar
+ 3
What jay said, or you could use if statements within the loop if (i == 1) func_1;
26th Jan 2018, 3:42 PM
Zeke Williams
Zeke Williams - avatar
+ 2
@jay @cubi* @zeke thanks for your help based on your suggestions i decided to directly call the function individually instead of using for loop as i felt there won't be much difference. so what do you guys think is it better or should i stick to for loop?
26th Jan 2018, 4:34 PM
‎ ‏‏‎Anonymous Guy
+ 1
It's definitely better. Go on practicing, the for loop was a good idea (although it doesn't work out).
26th Jan 2018, 5:29 PM
Timon Paßlick