When you do in fact want your function to return something and pass information back to the rest of your program, C++ has you covered. Just like there are many variable types, there are many different return types for functions.

A function can return most data types we’ve covered, including double, int, bool, char, std::string, and std::vector.

std::string always_blue() { return "blue!\n"; }

Note: The return statement is the last line of code that a function will execute. For example:

std::string always_blue() { return "blue!\n"; std::cout << "Returned blue!"; }

The final line will not execute because a value has already been returned. So "Returned blue!" won’t be printed to the terminal.



Convert needs_it_support() from a void function into a bool type function.


We’re currently printing support at the end of the function body.

Remove that print statement. Instead, return support from the function.

Inside of main(), print the result of needs_it_support() to the terminal.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?