Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 09-11-2007, 07:20 AM   #1 (permalink)
Sarkoff
Recruit
 
Join Date: Jul 2007
Posts: 3
Sarkoff is on a distinguished road
Dereferencing a function pointer

What is the difference between dereferencing a function pointer explicitly vs. dereferencing one implicitly? My book says they both work equally well. However are there any performance issues or other minor issues I should be aware of?
Sarkoff is offline   Reply With Quote
Old 09-11-2007, 08:54 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,693
redhead is on a distinguished road
To quote Peter's notes
Quote:
The first method is with an implicit conversion to pointer:
Code:
       funcptr = f;
The second method is with an explicit manufacture of a pointer:
Code:
       funcptr = &f;
Both ways are completely equivalent (AFAIK) and completely legal. You might think that the explicit method is more consistent because it's analogous to how we get the address of objects. However, the first method is shorter and cleaner. It's up to you.
And to widen the explanation with some wise words from The C++ Tutorial
Quote:
The implicit dereference method looks just like a normal function call — which is what you’d expect, since normal function names are pointers to functions anyway! However, some older compilers do not support the implicit dereference method, but all modern compilers should.
So there you have it, they are the same, however, some older compilers wont support implicit dereferencing.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with pointers Blondie Standard C, C++ 7 12-04-2006 01:55 PM
php $_POST with multiple hidden form elements madhumati PHP 2 03-19-2006 07:26 AM
change the empty function from the old format to the new format powah All Other Coding Languages 1 07-10-2005 01:23 PM
Function returning pointer lostromos Standard C, C++ 3 04-19-2005 02:34 AM
pointer to function with class? Kportertx Standard C, C++ 5 04-11-2003 05:12 AM


All times are GMT -8. The time now is 12:43 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting