473,786 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what is this definition?

double ** matrix;
struct data_point
{
float x,y,z;
float nx,ny,nz;
float value;
};

Hi I have the following function definition. My question is what is
basic_func in that definition?
I have never seen this before. Can anyone tell me what it means?
matrix and data_point you can see them declared above, and inside the
function this is the only other place where basic_func is mentioned in
the code I am pasting from.

void makematrix_poly ( double (*basic_func)(d ata_point *, data_point *) )
{
//....

matrix[pi+1][si+1] = (*basic_func)(& points[pi], &points[si]);

//....

}
Jul 22 '05 #1
3 1381
"Guybrush Threepwood" <sa***@sco.co m> wrote in message
news:c2******** **@newsg4.svr.p ol.co.uk...
double ** matrix;
struct data_point
{
float x,y,z;
float nx,ny,nz;
float value;
};

Hi I have the following function definition. My question is what is
basic_func in that definition?
I have never seen this before. Can anyone tell me what it means?
matrix and data_point you can see them declared above, and inside the
function this is the only other place where basic_func is mentioned in
the code I am pasting from.

void makematrix_poly ( double (*basic_func)(d ata_point *, data_point *) )
'basic_func' is a pointer to a function returing a double and taking two
'data_point' pointers as its arguments. To make it clearer, you usually use
a typedef and use the typdef'd name in the function:

typedef double (*pbasic_func)( data_point *, data_point *);
void makematrix_poly ( pbasic_func basic_func )
{
//....

matrix[pi+1][si+1] = (*basic_func)(& points[pi], &points[si]);

//....

}


hth
--
jb

(replace y with x if you want to reply by e-mail)
Jul 22 '05 #2

hth
yes it does. Thank you
--
jb

(replace y with x if you want to reply by e-mail)

Jul 22 '05 #3
"Guybrush Threepwood" <sa***@sco.co m> wrote in message
news:c2******** **@newsg4.svr.p ol.co.uk...
double ** matrix;
struct data_point
{
float x,y,z;
float nx,ny,nz;
float value;
};

Hi I have the following function definition. My question is what is
basic_func in that definition?
I have never seen this before. Can anyone tell me what it means?
matrix and data_point you can see them declared above, and inside the
function this is the only other place where basic_func is mentioned in
the code I am pasting from.

void makematrix_poly ( double (*basic_func)(d ata_point *, data_point *) )
{
//....

matrix[pi+1][si+1] = (*basic_func)(& points[pi], &points[si]);

//....

}


double (*basic_func)(d ata_point *, data_point *)

Starting from the identifier (basic_func), the first operator in order of
precedence is * (dereference), so basic_func is a pointer (i.e., in an
expression, * dereferences the pointer to yield the object it points to).
The next operator is () (function call), so basic_func is a pointer to a
function. The rest of it is like any other function (parameters and return
type). So the complete type is: pointer to a function taking parameters
data_point *, data_point * and returning a double.

Note that the parentheses around *basic_func are necessary because the
function call parentheses have higher precedence than *. If they weren't
there you would have:
double *basic_func(dat a_point *, data_point *)

This time, the function call parentheses have the highest precedence, so
basic_func is a function. The * comes next, so it's a function returning a
pointer. The whole type is: function taking parameters data_point *,
data_point * and returning a double*.

(*basic_func)(& points[pi], &points[si]);

In the actual call, the pointer to function is dereferenced (*basic_func),
yielding the function itself. The rest is the same as an ordinary function
call.

DW

Jul 22 '05 #4

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

Similar topics

112
10368
by: Andy | last post by:
Hi All! We are doing new development for SQL Server 2000 and also moving from SQL 7.0 to SQL Server 2000. What are cons and pros for using IDENTITY property as PK in SQL SERVER 2000? Please, share your experience in using IDENTITY as PK .
31
2807
by: Steven T. Hatton | last post by:
If a header is not necessarily a source file, and the sequences delimited by < and > in header names aren't necessarily valid source file names, what exactly is a header? -- p->m == (*p).m == p.m http://www.kdevelop.org http://www.suse.com http://www.mozilla.org
4
1739
by: John | last post by:
Hi all; I write my first code using vector and list. When I run it, segmentation fault. Try to debug it, but it can not pass linking with -g option. What is the error with it? Thanks a lot. John
5
2241
by: Andy | last post by:
Hi, I got a little confused on 'instantiation' and 'specialization', espcially for explicit instantiation and explicit sepcialization. Can anybody explain the difference? Thanks a lot! Andy
15
6733
by: Greenhorn | last post by:
Hi, when a function doesn't specify a return type ,value what value is returned. In the below programme, the function sample()is returning the value passed to 'k'. sample(int); main() { int i = 0,j; j = sample(0);
18
3864
by: Seigfried | last post by:
I have to write a paper about object oriented programming and I'm doing some reading to make sure I understand it. In a book I'm reading, however, polymorphism is defined as: "the ability of two different objects to respond to the same request message in their own unique way" I thought that it was: "the ability of same object to respond to different messages in
669
26221
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
11
4637
by: satyspiceoflife | last post by:
int x,a; a=10 x=&a; cout<<*x; //using dereference operator this will print value 10 the other case is int *x; //x is a pointer variable int a=10; x=&a;
14
4631
by: =?Utf-8?B?QUEyZTcyRQ==?= | last post by:
Am I correct in thinking that the <signatureof a function is its <syntax> i.e. the arguments and the order in which they are specified when calling the function?
92
6258
by: Heinrich Pumpernickel | last post by:
what does this warning mean ? #include <stdio.h> int main() { long l = 100; printf("l is %li\n", l * 10L);
0
9647
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9491
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
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
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
10104
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
8988
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 projectplanning, coding, testing, and deploymentwithout 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...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4063
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

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.