🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Return types

Started by
0 comments, last by chris2doragon 22 years, 6 months ago
Can someone help explain to me what return types actually do.
Advertisement
Return types are the pendant of parameter types. When you call a function, you have to give it parameters of a given type. Well, if that function returns a result, the return type is ... the type of the value it returns.

e.g. double foo( int x ) { return x/2.0; };
The type of x is int, the return type is double, which means that when I type foo( 5 ), the value I get is a double, and I should store it in a variable of type double (unless I really know what I am doing).
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement