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.
Loading...
Related Quiz
- You are tasked with writing a C function to calculate the factorial of a number. Which programming technique would be most suitable for this task?
- In a program that processes 3D graphics, you need to calculate the distance between points in space. What concept would be useful in efficiently handling the coordinates of these points?
- What is the standard notation for passing command line arguments in a C program?
- When you declare an array, what does the number inside the square brackets represent?
- How does C++ resolve calls to overloaded functions?