944,103 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 649
  • C++ RSS
Oct 26th, 2007
0

The * in a function.

Expand Post »
The Function

double *solve( double a[ ][N], double b[ ])

what does the pointer notation * represent in front of solve?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
warpstar is offline Offline
15 posts
since Oct 2007
Oct 26th, 2007
0

Re: The * in a function.

It means the function is going to return a pointer to a double variable or possibly a pointer to an array of doubles. The * means a pointer.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,961 posts
since Aug 2005
Oct 26th, 2007
3

Re: The * in a function.

Read it as if the * sticks to the type name, not the function name.
Team Colleague
Reputation Points: 1135
Solved Threads: 172
Super Senior Demiposter
Rashakil Fol is offline Offline
2,479 posts
since Jun 2005
Oct 27th, 2007
1

Re: The * in a function.

Pointer syntax in C/C++ is very flexible, but likewise very confusing. You can say something like
int i, *pi, **ppi;
but this should be read carefully as
int i;
int* pi;
int** ppi;

:an integer, a pointer to an integer, and a pointer to a pointer to an integer. Yeah, I know... read it again anyway... (I attached the "*" to the int because it is part of the type of each variable, but it could be anywhere between the base type and the variable name.)

In C, you are forgiven a lot when dealing with the type of things. Hence, as already mentioned, the variable int* pi can be a pointer to a single integer or a pointer to a whole lot of them. Typically, programmers will state their intent by saying either
int *a --pointer to a single int, or
int a[] --pointer to an array of ints.
However, you can't use the [] brackets when declaring a function return type, so you are stuck with the *.

Hope this helps.
Last edited by Duoas; Oct 27th, 2007 at 12:42 am.
Featured Poster
Reputation Points: 1140
Solved Threads: 229
Postaholic
Duoas is offline Offline
2,039 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: learning WIN32 GDI
Next Thread in C++ Forum Timeline: Whats the difference between...plz respond in the next 5-10min





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC