Can anybody explain this snippet for me?

W

webinfinite

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.
 
V

Victor Bazarov

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top