Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
say we have this function :
Function ov(byval a as integer)

Return ov(a)
End function

As far as I know the program will crash because it will keep storing the 'a' variable in memory as a different variable each time

But can this :
Function ov(byref a as integer)
a=0 
Return ov(a)
End function

crash the programm or it will continue to run until the plug is pulled ?

Thank you very much ! :)
Posted
Comments
[no name] 27-Apr-14 13:31pm    
Try it and find out. You will probably get a stack overflow exception as you never exit the function.

For a recursive function to stop calling itself we require some type of stopping condition.

both types of your recursive methods will hang because of no Stop condition
 
Share this answer
 
v2
It will crash eventually.

Why? Because when you call a function a return address is pushed onto the stack so the processor can know where to return to. Constantly pushing a return address onto the stack will eventually exhaust it, causing a StackOverflowException.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900