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.
Loading...
Related Quiz
- What is the purpose of the 'sizeof' operator in C?
- The ______ function in C can be used to change the position of the file pointer in a stream.
- What is the main purpose of using pointers in a C program?
- When dealing with large files, what is the advantage of using fread and fwrite over fscanf and fprintf?
- The memory consumed by an array declared as float arr[10][20]; is ________.