Alex Rivera | Logout

Can I re-define a function or check if it exists?

Asked 2011-08-02T18:28:36.103
12

I have a question about (re-)defining functions. My goal is to have a script where I can choose to define a function or not. Like this:

void func(){}

int main(){
   if (func)func();
}

AND without the function, just:

int main(){
   if (func)func();
}

Anybody an idea?

Edit
Report

1 Answer

4

Use function pointers, set them dynamically based on runtime conditions, and check for null pointers or wrap them in methods that do that check for you.

Only option in C I can think of.

In C++ you could combine templates and DLLs to dynamically define at runtime.

answered 2011-08-02T18:37:12.290

Your Answer