CSE2305 - Object-Oriented Software Engineering
Self Assesment Questions
For each question choose the single response which best answers the question, or which completes the statement most accurately.
| Question 47: | What is a function pointer useful for? |
| Telling the hardware which function is to be called next |
| Providing a form of polymorphism in imperative languages (such as C) |
| Linking a series of function calls (analogous to a linked list of data) |
| Ensuring that a function returns to the correct place in the code, after it executes |
| Passing parameters to a function in a language which does not have references |
| Question 48: | Which of the following is a valid C/C++ function pointer definition |
| int *(f)(); |
| int* f(); |
| (int*)f(); |
| (int* f)(); |
| None of the above |
| Question 49: | Which of the following declares a pointer to a function g, which takes two ints and returns nothing? |
| (*g)(int*2); |
| (*g)(int,int); |
| void (*g)(int,int); |
| (*g)(int,int) = void; |
| *(void g(int,int)); |
| Question 50: | Which of the following is a correct call to the function pointed to by the function pointer g? |
| g->(1,2); |
| g(1,2); |
| *g(1,2); |
| (*g)(1,2); |
| void (*g)(1,2); |
| Question 51: | What is the relationship between function pointers and polymorphism? |
| Function pointers allow us to implement a form of polymorphism |
| Function pointers allow us to prevent polymorphism |
| Function pointers are a necessary prerequisite for polymorphism |
| Function pointers make polymorphism necessary in a program |
| There is no relationship between function pointers and polymorphism |
Last updated: July 27, 2005