Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Lohrno

returning without ending the function?

This topic is 5986 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible for a function to return a value without breaking out of the function? And if so, could I ask how? =D -=Lohrno

Share this post


Link to post
Share on other sites
Advertisement
Not in c/c++. You'll have to call another function passing whatever values you want to pass.

Edited by - lessbread on February 25, 2002 1:00:27 AM

Share this post


Link to post
Share on other sites
Pass a value to the function by pointer, and then modify it from within the function. Unless your program involves multiple threads, or has some sort of time dependency along with another process (or something equally ignominious), I don''t know why you would need to, though.

Share this post


Link to post
Share on other sites
Aww...you mean I have to use a reference =( I hate adding
parameters to my functions =(

And no, I''m not using any any goto lines sorry...I may be evil,
but thats just crossing the line!

-=Lohrno

Share this post


Link to post
Share on other sites
umm... no params? How about a global var then? Why dont you describe what you are trying to accomplish?

Share this post


Link to post
Share on other sites
quote:
Original post by Lohrno
Is it possible for a function to return a value without breaking
out of the function?


That doesn''t make any sense. If you haven''t "broken out of the function", then you haven''t returned. What is it that you are trying to achieve?

--

When horses lift their heads up high to look at something, they''re looking far into the distance. To see things that are closer, they lower their heads.

Share this post


Link to post
Share on other sites
there is a problem though. You can only have one function running at a time. So If you want to check what value a funciton has returned from another function, you need to exit the first function so that you can run the second function, totally defeating your purpose. The reason is your processor can only execute on instruction at a time. With your functions being a list of instructions, you cannot have more than one list active at a time.p
The only possible way would be to have your functions run off of somekind of step-wise style that you could regulate from your main function.
In most cases, if there is something you want to do after you return the value you could just make another function to do that stuff.

...maybe dual processors might be able to get two functions running at the same time...

Share this post


Link to post
Share on other sites
It is possible to have multiple functions running "at the same time" (or to simulate the effect), using mechanisms such as threading or asynchronous function call. However, once a function returns, by definition it has completed. I suspect that, as often happens, the OP has a problem, and is assuming a particular solution rather than asking how to approach solving the problem.

--

When horses lift their heads up high to look at something, they''re looking far into the distance. To see things that are closer, they lower their heads.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!