Which of the following is a correct way to declare a function pointer in C++?
- int func()
- int *func()
- int (*func)()
- int &func()
In C++, a function pointer points to the address of a function. The correct syntax for declaring a function pointer is type (*pointer_name) (parameter list). In the given options, int (*func)() is the correct way to declare a function pointer returning an int.
Loading...
Related Quiz
- What is a potential risk of using recursion?
- Which loop structure is guaranteed to execute at least once even if the condition is false?
- Consider a class hierarchy with Base and Derived classes. An object of Derived throws an exception that is caught in a catch block for Base exceptions. What considerations might be relevant to the use of dynamic_cast inside the catch block?
- What is the purpose of a conversion constructor in C++?
- The operator used to determine the remainder when one number is divided by another is _______.