Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
116 views
in Technique[技术] by (71.8m points)

c++ - stack of void pointer calling it's function

stack<void*> g_stack;
bool stack_push(void (*Function)())
{
    if (Function != nullptr)
    {
        g_stack.push(Function);
        return true;
    }

    return false;
}

void stack_pop(void)
{
    g_stack.pop();
}

bool stack_process(void)
{

        if (g_stack.top() == nullptr)
            return false;

    
        void *f = g_stack.top();
        
        return true;
}

void Func1() { cout << "1" << std::endl; stack_pop();  }

I'm pushing some function pointers on the stack I want to get the top and call that function I'm pushing for example Func1() on the stack void *f = g_stack.top(); how do I call it ?

question from:https://stackoverflow.com/questions/65935875/stack-of-void-pointer-calling-its-function

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...