Thread: what does int*& foo mean in a user defined function?

  1. #1
    Registered User
    Join Date
    May 2013
    Posts
    66

    what does int*& foo mean in a user defined function?

    sorry im still learning. I have been tasked with creating a linear search program for a 10 element array for class. while reading links on google i found one that uses the following code:

    Code:
    bool jw_search ( node*& list, int key, int*& rec )
    the bool i get as that is simple in the man page, but what are the node*& and the int*& and what are they telling me?

    Thank you.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    that's not C code, it's C++. it's passing references to pointers as parameters to jw_search. the purpose being that jw_search can modify those pointers in such a way that the caller can see the changes.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    In this context, it is invalid syntax. However, you are probably looking at C++ code, in which case it declares rec to be a reference to a pointer to int.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    May 2013
    Posts
    66
    well that explains why i have no clue what im looking at.

    Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. User-defined function
    By ulti-killer in forum C Programming
    Replies: 5
    Last Post: 06-10-2012, 05:27 AM
  2. User defined function problem
    By 337higgin in forum C Programming
    Replies: 9
    Last Post: 10-03-2011, 04:01 PM
  3. User defined cos function
    By zfite in forum C Programming
    Replies: 11
    Last Post: 04-03-2011, 02:40 AM
  4. Replies: 14
    Last Post: 03-02-2008, 01:27 PM
  5. Calling a user-defined function in C++
    By brianptodd in forum C++ Programming
    Replies: 3
    Last Post: 10-08-2002, 12:09 PM