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 |
How to find the given no is odd or even without checking of any condition and loops. (Hint: Using array)
when will be evaluated as true/ if(x==x==x) a) x=1; b) x=0; c) x=-1; d) none
What is your stream meaning?
Is double link list a linear data structure? If Yes, Why?If No, Why?
What is volatile variable in c?
What are the __date__ and __time__ preprocessor commands?
Describe the header file and its usage in c programming?
difference between ordinary variable and pointer in C?
How do I copy files?
what is an inline fuction??
What is wrong with this declaration?
in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none