pointers and functions

Discussion in 'C++' started by Ying Yang, Sep 9, 2003.

  1. Ying Yang

    Ying Yang Guest

    Hi,

    Consider this function:

    Node2* insertNode (Node1* node){
    ...
    }


    What is this function returning exactly?

    1. a pointer of type Node2 OR
    2. the contents of what Node2 references.

    I think 1.


    wewewewe



    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.510 / Virus Database: 307 - Release Date: 14/08/2003
    Ying Yang, Sep 9, 2003
    #1
    1. Advertising

  2. Ying Yang

    Sumit Rajan Guest

    Ying Yang wrote:

    > Hi,
    >
    > Consider this function:
    >
    > Node2* insertNode (Node1* node){
    > ...
    > }
    >
    >
    > What is this function returning exactly?
    >
    > 1. a pointer of type Node2 OR
    > 2. the contents of what Node2 references.
    >
    > I think 1.
    >


    insertNode returns a pointer to Node2

    Sumit.
    Sumit Rajan, Sep 9, 2003
    #2
    1. Advertising

  3. Ying Yang

    Howard Guest

    "Ying Yang" <> wrote in message
    news:3f5da3b5$...
    > Hi,
    >
    > Consider this function:
    >
    > Node2* insertNode (Node1* node){
    > ...
    > }
    >
    >
    > What is this function returning exactly?
    >
    > 1. a pointer of type Node2 OR
    > 2. the contents of what Node2 references.
    >
    > I think 1.
    >


    It doesn't actually return "a pointer of type Node2". It returns "a
    pointer to an object of type Node2". (But of course, it could return nil as
    well, which technically doesn't point to anything.)

    Saying "a pointer of type Node2" tends to imply that Node2 is a pointer
    type and a pointer of that type is being returned, whereas here you are
    returning a pointer, and what it points to is an object whose type is Node2.
    But maybe I'm just being picky. :)

    -Howard
    Howard, Sep 9, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. S?ren Gammelmark
    Replies:
    1
    Views:
    1,867
    Eric Sosman
    Jan 7, 2005
  2. Marc Thrun
    Replies:
    15
    Views:
    850
    Tim Rentsch
    Oct 4, 2005
  3. newbie

    Pointers to char pointers in functions

    newbie, Sep 18, 2006, in forum: C Programming
    Replies:
    9
    Views:
    300
    August Karlstrom
    Sep 24, 2006
  4. cerr

    pointers, pointers, pointers...

    cerr, Apr 7, 2011, in forum: C Programming
    Replies:
    12
    Views:
    656
  5. ajaybgr
    Replies:
    18
    Views:
    951
    Philip Lantz
    Sep 7, 2012
Loading...

Share This Page