The C++Course provides a general introduction to programming in C++. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details. |
![]() |
Home ![]() ![]() |
||
See also: Functions with Multiple Parameters, The Return Statement, Pure Functions, Return Values, Programs with Multiple Functions | ||
![]() ![]() ![]() ![]() ![]() ![]() |
||
Functions with Results
You might have noticed by now that some of the functions we are using, like the math functions, yield results. Other functions, like newLine, perform an action but don't return a value. That raises some questions:
The answer to the third question is "yes, you can write functions that return values," and we'll do it in a couple of chapters. I will leave it up to you to answer the other two questions by trying them out. Any time you have a question about what is legal or illegal in C++, a good way to find out is to ask the compiler.
|
||
Home ![]() ![]() |