What is Function Pointer? Explain with example?
Answers were Sorted based on User's Feedback
Answer / inderchauhan
A pointer is a special kind of variable in C and C++ that
holds the address of another variable.
my first pointer
#include <iostream>
using namespace std;
int main ()
{
int firstvalue, secondvalue;
int * mypointer;
mypointer = &firstvalue;
*mypointer = 10;
mypointer = &secondvalue;
*mypointer = 20;
cout << "firstvalue is " << firstvalue << endl;
cout << "secondvalue is " << secondvalue << endl;
return 0;
}
firstvalue is 10
secondvalue is 20
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / sanjay bhosale
function pointer is simply a pointer which holds the address of the function so we can call that function by using pointer.
It is helpful in situations where we are required to pass the function pointer as parameter to some previously defined functions.
for e.g.
in comparison method we may pass function pointer for function which will compare 2 items/objects and help to comparison method.
Is This Answer Correct ? | 0 Yes | 0 No |
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
0 Answers Lovely Professional University,
Why enum is used in c?
How do you list files in a directory?
write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! =1+24+120 =145]
Why main is not a keyword in c?
What is volatile variable in c?
Write code for finding depth of tree
How many loops are there in c?
What are shell structures used for?
Write a C Program That Will Count The Number Of Even And Odd Integers In A Set using while loop
When should a type cast be used?
24.what is a void pointer? 25.why arithmetic operation can’t be performed on a void pointer? 26.differentiate between const char *a; char *const a; and char const *a; 27.compare array with pointer? 28.what is a NULL pointer? 29.what does ‘segmentation violation’ mean? 30.what does ‘Bus Error’ mean? 31.Define function pointers? 32.How do you initialize function pointers? Give an example? 33.where can function pointers be used?