A Little Agency Melissa Setszip

! Download the best multitasking tasks manager for Windows: Windows Tasks Assistant.. It can be attached to any existing mail icon and it acts as a. Melissa and.Q:

Peculiar behavior of for loop of this function in C++

I have a function inside main() in C++. I’ll put a piece of code to make it more understandable:
void **void_params(void **(*func) (void **par))
**func = func_new(0);
*func = func_new(1);

void* func_new(int i) {
if (i == 1) {
cout << "i is 1 "; } else { cout << "i is 2 "; } return nullptr; } For this particular example, i call the void_params() as: void_params(&func_new); The output of this is: i is 2 The output of the commented line is i is 1 Since the if condition for the function func_new() is satisfied for the first time, I would assume it to execute the statement marked by "**func = func_new(1)" in the function void_params(). But what actually happens is that the statement marked by "**func = func_new(1)" executes only when the outer if-loop is executed the second time. How is it possible? Edit: The reason for the doubt was my understanding of the first time the condition in a if-statement is checked. Now I understand it correctly. However, this is more of a logical doubt. A solution to the problem is changing the code a bit. Instead of passing a function as void_params(void **), I would pass a pointer to the function as void_params(void *). And the code to be changed to is: void **void_params(void *(*func) (void **par)) { *func = func_new(0); *func = func_new(1); } void* func_new(int i) { if (i == 1) {