473,779 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Difference between function pointers

What is the difference between
(int *) fun() and int *fun() ?

What is the advantage of pointers to functions?
Jul 25 '08 #1
11 1499
ram kishore wrote:
What is the difference between
(int *) fun() and int *fun() ?

What is the advantage of pointers to functions?
Do your own homework

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Jul 25 '08 #2
ram kishore said:
What is the difference between
(int *) fun() and int *fun() ?
()
What is the advantage of pointers to functions?
When you need to point to a function, nothing beats them.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 25 '08 #3
zR0
On Jul 25, 12:19*pm, ram kishore <rapol...@gmail .comwrote:
What *is the difference between
(int *) fun() and int *fun() ?

What is the advantage of pointers to functions?
This can be a good resource on this topic.
http://www.newty.de/fpt/index.html
Jul 25 '08 #4
zR0 <ro************ ***@gmail.comwr ote:
On Jul 25, 12:19=A0pm, ram kishore <rapol...@gmail .comwrote:
What =A0is the difference between
(int *) fun() and int *fun() ?

What is the advantage of pointers to functions?

This can be a good resource on this topic.
http://www.newty.de/fpt/index.html
Not if you're programming in C, it can't. That's very C++-oriented.

Richard
Jul 25 '08 #5
On 25 Jul, 08:19, ram kishore <rapol...@gmail .comwrote:
What *is the difference between
(int *) fun() and int *fun() ?
one gives a syntax error the other doesn't
What is the advantage of pointers to functions?
1. call backs
2. threaded interpreters
3. really cool looking code

look up qsort() in your textbook

--
Nick Keighley

Error on line 0: Lazy programmer.
Jul 25 '08 #6
Nick Keighley <ni************ ******@hotmail. comwrites:
On 25 Jul, 08:19, ram kishore <rapol...@gmail .comwrote:
>What *is the difference between
(int *) fun() and int *fun() ?

one gives a syntax error the other doesn't
[...]

Not necessarily. I just wrote a small syntactically correct program
that uses both constructs. But one of them probably doesn't mean what
the OP thinks it means.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 25 '08 #7
ram kishore wrote:
What is the advantage of pointers to functions?
All function calls are made
with an operand of pointer to function type.

--
pete
Jul 26 '08 #8
pete <pf*****@mindsp ring.comwrites:
ram kishore wrote:
>What is the advantage of pointers to functions?

All function calls are made
with an operand of pointer to function type.
True.

Then the question the OP should have asked is:

What is the advantage of pointers to functions other than those that
result from the implicit conversion of a function name used as the
prefix of a function call?

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 26 '08 #9
Keith Thompson wrote:
pete <pf*****@mindsp ring.comwrites:
>ram kishore wrote:
>>What is the advantage of pointers to functions?
All function calls are made
with an operand of pointer to function type.

True.

Then the question the OP should have asked is:

What is the advantage of pointers to functions other than those that
result from the implicit conversion of a function name used as the
prefix of a function call?
I recall recently,
in one of the web pages from a URL posted to this newsgroup,
advice that function calls should properly be made this way:
either
function_name() ;
or
(*function_poin ter)();

I wouldn't write function calls differently
for function name versus pointer constructs,
but if I would, I would do it this way:
either
(&function_name )();
or
function_pointe r();

The other way doesn't make any sense.

--
pete
Jul 26 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
14201
by: rahul8143 | last post by:
hello, I require a single c++ program that will illustrate usage of this,far,near pointers. Can any body please explain me those pointers? regards, rahul.
2
4305
by: duyifan.nju | last post by:
hello, can someone tell me what is the difference between sort() (in stl) & qsort(stdlib.h) thanks in advance.
24
3637
by: wwj | last post by:
Hi ,all I want to know the difference between char a and char *p=new char and the difference between the heap and the stack ,and if the char a is corresponding to the stack in MEMORY,and char *p=new char is corresponding to the heap of MEMORY. Give me some hint. THANK YOU.
59
3578
by: Ramkumar R K | last post by:
what is the difference between objects and pointers?
79
3436
by: Me | last post by:
Just a question/observation out of frustration. I read in depth the book by Peter Van Der Linden entitled "Expert C Programming" (Deep C Secrets). In particular the chapters entitled: 4: The Shocking Truth: C Arrays and Pointers Are NOT the Same! 9: More about Arrays 10: More about Pointers What blows me out of the water is the fact that 'every' programmer
8
11183
by: venkatesh | last post by:
hai to everybody, i am having doubt in difference between the malloc and calloc function. please tell where to use and when to use those functions?
14
2039
by: code break | last post by:
what is the difference in this pointers decalarition ? int *ptr; and int (*ptr);
10
16675
by: ravi | last post by:
Hi, i am a c++ programmer, now i want to learn programming in c also. so can anybody explain me the difference b/w call by reference and call by pointer (with example if possible).
6
4929
by: mthread | last post by:
Hi, I am learning C++ and I have been told that an object can be created either by using calloc or new. If it is true, can some one tell me what is the difference b/w using these two function calls.
0
9632
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9471
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8958
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7478
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.