In a graphics rendering engine, you need to apply different transformations (e.g., rotate, scale, translate) to objects. How can function pointers be used to simplify the implementation?

  • Define a function pointer for each transformation type
  • Use if-else statements to select transformations
  • Use global variables to store transformation functions
  • Implement each transformation directly in the code
Option A is the correct answer. By defining a function pointer for each transformation type, you can easily switch between different transformations without altering the engine's core logic. Options B, C, and D are less flexible and efficient. Option A simplifies the code.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *