What are helper functions in C++?

后端 未结 4 799
难免孤独
难免孤独 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:07

    An example could be the input validation function that you will be reusing in the entire main function. Let's say you have a program that asks for the user's age, since age is an integer > 0, you'll need to have a separate function that takes care of the "cin >> users_age;". If the input satisfies the condition statement then proceed, otherwise ask the user to re-enter their age.

    This is just an example of "helper function". Correct me readers if I'm wrong. Thanks!

提交回复
热议问题