What are helper functions in C++?

后端 未结 4 796
难免孤独
难免孤独 2021-01-31 09:50

I was trying to understand helper functions in C++ from The C++ Programming Language by Bjarne Stroustrup. But the book hasn\'t explained anything about it and the

4条回答
  •  失恋的感觉
    2021-01-31 10:15

    There is a great definition of a helper function from the CppCoreGuidline:

    A helper function is a function (usually supplied by the writer of a class) that does not need direct access to the representation of the class, yet is seen as part of the useful interface to the class. Placing them in the same namespace as the class makes their relationship to the class obvious and allows them to be found by argument dependent lookup.

    For more info you can check the paragraph with a clear example, from which the upper quote is taken.

提交回复
热议问题