You are developing a library of mathematical functions. How can you design the library to allow users to apply custom operations on data without modifying the library code?

  • Use function pointers
  • Use inheritance and polymorphism
  • Use global variables
  • Use the preprocessor macro
Option A is the correct answer. Using function pointers allows users to pass custom functions to the library without modifying the library's code. Option B (inheritance and polymorphism) is a valid design approach but doesn't allow users to apply custom operations easily. Options C and D are not suitable for this purpose.
Add your answer
Loading...

Leave a comment

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