Visit Our UNIX and Linux User Community


question about Function pointers


 
Thread Tools Search this Thread
Top Forums Programming question about Function pointers
# 1  
Old 11-16-2010
MySQL question about Function pointers

Hello forum memebers


As iam new to C++ programming i am little bit confuse to understand the function pointers.
Please help me to understand the function pointers with examples are suggest me good site for this,Its better if it have picturial representation ie any PPTS available in Google.


I am looking forward from you ASAP.


Thanks & Regards
Rajkumar.g
# 2  
Old 11-16-2010
# 3  
Old 11-16-2010
The syntax to use a function pointer is a little tricky, but the concept isn't hard at all if you know what a pointer is. It's just a pointer, that points to a function, because functions reside in memory too.

When you call a function name in C, what you're actually doing is calling an address in memory where the function's code resides. Most of the linker's job is to figure out where everything should go and substitute appropriate addresses for names. So, whenever you call a function, it actually ends up as a hardcoded address...

It's also possible to call an arbitrary address; for instance, if you loaded a dynamic library, you have to use function pointers to call functions from it since you won't know what they will be until the library's loaded. It works the same as far as the code's concerned. It just uses a pointer value you give it, instead of hardcoding one.
This User Gave Thanks to Corona688 For This Post:

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

How to Declare an array of function pointers?

I am attempting to create an array of function pointers. The examples I follow to do this are from: support.microsoft.com/en-us/help/30580/how-to-declare-an-array-of-pointers-to-functions-in-visual-c ... (3 Replies)
Discussion started by: spflanze
3 Replies

2. Programming

question about function object

I have a code as following: #include <iostream> #include <algorithm> #include <list> using namespace std; //the class Nth is a predicates class Nth{ private: int nth; int count; public: Nth(int n):nth(n),count(0){} bool operator()(int){ ... (2 Replies)
Discussion started by: homeboy
2 Replies

3. Shell Programming and Scripting

Question about Function calls

Hello everyone, here's my problem: I want to create two shell scripts. one of them should includes some functions, the other one just the function calls. Is this possible? Can i call a function which is placed in a scriptfile eg functions.sh out of another script eg call.sh? :confused: And if... (2 Replies)
Discussion started by: Sebi0815
2 Replies

4. Programming

Question with pointers and free()

Just a statement I need some clarification Im aware that malloc() can be used to create pointers, and free() is used to deallocate dynamic memory, however is free() the ONLY way to dispose of the dynamic memory, because not using free() means the dynamic memory still exists and it may cause some... (1 Reply)
Discussion started by: JamesGoh
1 Replies

5. Programming

Question about the system() function in C

Hello all ! Could someone throw some light on whether there's a limit to the number of characters contained in the command string that is passed to the system() call in C. Is it OS dependent? If yes, what are the limits for each? Thanks. (4 Replies)
Discussion started by: vsanjit
4 Replies

6. Programming

Regarding Function and Pointers.

HI, Here is some thing that is puzzling me from a long time. Can some body explain me this with example. The question is :- What is the difference between function pointer and pointer to a function. Where do we actually use the function pointers and pointer to functions. Thanks in... (0 Replies)
Discussion started by: S.Vishwanath
0 Replies

7. UNIX for Dummies Questions & Answers

Date function question

hi guys! just want to ask if you could help me with the sript i'm working on. i need to automatically generate a summarized report everyday for all transactions the day before and ftp it to another machine. my only problem is that i need to name the file as the date yesterday. for example if i... (12 Replies)
Discussion started by: crpalermo
12 Replies

8. Shell Programming and Scripting

Question about function

/ (6 Replies)
Discussion started by: jy2728
6 Replies

9. Programming

Sharing C++ Objects with virtual function table pointers

I am pondering the next question: Can I safely sare objects that have virtual functions (i.e. have virtual function table pointers) between two processes ? Where will the pointers point to in each process ? What I am afraid of is that in the creating process the pointer will indeed point to... (2 Replies)
Discussion started by: Seeker
2 Replies

Featured Tech Videos