0

C++ how do you know what to return.

I am struggling with the return value. How do you know if you have to return something or that you don't have to return something (through void or a constructor).

27th Aug 2018, 6:54 PM
Sabine Meijran-Prins
Sabine Meijran-Prins - avatar
4 Answers
27th Aug 2018, 9:56 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 2
depends on what you want to use your function for. You just want it to print text to console? No need to return then, use void. You want it to generate random integer? Return int. Your function performs some math operatioms and returns tge result which may not be an integer? return double it comes down to what you plan your functions to do
27th Aug 2018, 8:43 PM
Data
Data - avatar
0
Thank you all :) It helped me a lot :) :)
29th Aug 2018, 9:44 AM
Sabine Meijran-Prins
Sabine Meijran-Prins - avatar