Can anybody explain this snippet for me?

Discussion in 'C++' started by webinfinite@gmail.com, Oct 22, 2007.

  1. Guest

    HI,

    I ran across a code written by somebody else. Since I am new to C++,
    could you please explain what each of "const *" means in this code
    snippet as well as the last "const"?

    Tool const* const* tool_array() const;

    Tool is an internal structure defined somewhere else. tool_array()
    gets an entire array of Tool type.


    Thank you.
    , Oct 22, 2007
    #1
    1. Advertising

  2. wrote:
    > I ran across a code written by somebody else. Since I am new to C++,
    > could you please explain what each of "const *" means in this code
    > snippet as well as the last "const"?
    >
    > Tool const* const* tool_array() const;
    >
    > Tool is an internal structure defined somewhere else. tool_array()
    > gets an entire array of Tool type.


    The function 'tool_array' is a non-static member function of some
    class. It returns a pointer to a constant pointer to a constant
    object of type Tool (those are the two 'const' between 'Tool' and
    the name of the function), and does not change the object for which
    it is called (that's the 'const' after the [empty] argument list):
    it can be called for a constant object.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Oct 22, 2007
    #2
    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. =?Utf-8?B?Tmljaw==?=
    Replies:
    2
    Views:
    425
    =?Utf-8?B?Tmljaw==?=
    Jan 11, 2006
  2. Colin Mackenzie
    Replies:
    0
    Views:
    1,092
    Colin Mackenzie
    Jul 3, 2003
  3. Marrow
    Replies:
    2
    Views:
    1,230
    Marrow
    Jul 7, 2003
  4. Replies:
    2
    Views:
    329
    VisionSet
    May 24, 2006
  5. Replies:
    0
    Views:
    226
Loading...

Share This Page