title: point to function in memory depending on context - polymorphism
body: <p>I would like to call a function depending on the context, it's the polymorphism idea I just can't seem to grasp.</p>
  
  <p>Is following example a plausible solution? where you create a struct and point to relevant function depending on Context:</p>
  
  <p><em>I know I should allocate memory for the stuct, which I am not doing in this pseudo code</em></p>
  
  <pre><code>struct ContextMethods{
     void (*memberMethod)();
  } ContextMethods;
  
  void debugFunction(){ returns debug info};
  void productionFunction( does usefull production stuff);
  void run(ContextMethods local_context);
  
  main(){
  
      struct ContextMethods local_struct;
  
      if(DEBUG){
          local_struct-&gt;memberMethod = &amp;debugFunction;
      }
      if(PRODUCTION){
          local_struct-&gt;memberMethod = &amp;productionFunction;
      }
  
      run(local_context);
  }
  
  run(local_context){
      local_context-&gt;memberMethod();
  }
  </code></pre>