Jump to content
The Lotus Eaters: Share Bug Reports and Feedback Here! ×

Last post wins


Mr.ElevenXI
 Share

Recommended Posts

10 minutes ago, Snyphurr said:

Or is it?

Yes

9 minutes ago, AerinSol said:

Well...as a foreigner all you people look the same...

You mean you tiny people are differant?

7 minutes ago, AerinSol said:

 

Proof that off-topic has always been epic.

Yes, more boobs and jiggle physics to extend our lives

5 minutes ago, Azrael said:

For you riven enthusiasts. I just did something stupid. I paid an ungodly amount of plat for this mod:

  Hide contents

9CGau6g.jpg?1

 

Nice riven

Link to comment
Share on other sites

29 minutes ago, GiraffaYandereBeetle said:

Ima having difficulty understanding the difference between a return function and void function in C++.

Any kind soul that could explain in a way that a numbskull like me should be able to understand?

it's been a while, so I may make some mistakes here. But if I recall correctly, a void function has no return value because it doesn't return anything. So you might use a void function to change something that has been passed by reference, while a return function would return a value that could be used by some other function.

So suppose you have a variable X. If you want to increase it by one, you might pass it to this function:

VOID increment(int input)

       { input += 1;}

 

Or you might pass it to this function

INT increment(int input)

     { return input + 1; }

in the second case, you haven't changed anything. So to increment X using the first function you would write:

increment(X);

But with the second function you would have to write:

X = increment(X);

 

A third option is to define the function as follows:

BOOL increment(int input)

     {

      input +=1;

     IF(conditions) {

           return 1;

    ELSE

         return 0;}}

 

This function returns a BOOL value which we might use as input validation. The "conditions" refers to error-checking code, although there are better ways to do this. The point is that there IS a return value, but it's not really related to what the function is doing. We are using it for something else.

These functions return some kind of value such as an INt or BOOL, whereas the first one needs no return value and therefore can be declared as a VOID function, because there's no need for a return type.

Link to comment
Share on other sites

1 minute ago, Azrael said:

it's been a while, so I may make some mistakes here. But if I recall correctly, a void function has no return value because it doesn't return anything. So you might use a void function to change something that has been passed by reference, while a return function would return a value that could be used by some other function.

So suppose you have a variable X. If you want to increase it by one, you might pass it to this function:

VOID increment(int input)

       { input += 1;}

 

Or you might pass it to this function

INT increment(int input)

     { return input + 1; }

in the second case, you haven't changed anything. So to increment X using the first function you would write:

increment(X);

But with the second function you would have to write:

X = increment(X);

 

A third option is to define the function as follows:

BOOL increment(int input)

     {

      input +=1;

     IF(conditions) {

           return 1;

    ELSE

         return 0;}}

 

This function returns a BOOL value which we might use as input validation. The "conditions" refers to error-checking code, although there are better ways to do this. The point is that there IS a return value, but it's not really related to what the function is doing. We are using it for something else.

These functions return some kind of value such as an INt or BOOL, whereas the first one needs no return value and therefore can be declared as a VOID function, because there's no need for a return type.

neeeeeerd alert!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...