K
K
Kezzya2019-02-10 15:02:18
C++ / C#
Kezzya, 2019-02-10 15:02:18

Function return, int/void what's the difference. C++?

I am using an int function, not a void, so it should remember the variables after it completes from the function. But that doesn't happen. Can someone explain?
I understand, looking ahead, that it will be possible to change somehow thanks to pointers. Haven't delved into it yet, but I'm more concerned with the difference between int and void now. After all, I thought that void is only a visual function, it does not return anything (to be honest, I hope I fully understand this word), and thanks to int, you can already work, somehow interact with the function.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2019-02-10
@Kezzya

For the screenshot code, you need to kill with a rusty ax of horror.
At you there Int is useless as a matter of fact.
Not only do you not assign the value that the function returns anywhere, you also return zero all the time.
Specifically, in your case - yes, it is necessary through pointers, because you want to modify variables passed from outside in the function, and even more than one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question