July 22nd, 2013, 02:12 PM
Can anyone please explain me this program
function x ()
function y ()
these x and y are confusing me....y is returned to function y and x is returned to function x.but both are not defined.when i run the program i got an error saying call to undefined function y()..
my doubts are
1)is x defined?? if so how?
2)why am i getting error when i call y() ????
Last edited by sam_sam56; July 22nd, 2013 at 02:24 PM.
Reason: to add one more doubt
July 22nd, 2013, 02:21 PM
You have function Y inside function X, you should have it separated.
July 22nd, 2013, 02:25 PM
Gosh, where do you got this from? Did your cat walk over the keyboard?
No, y is not defined, because it only gets defined when you call x. But if you call x more than once, you get an redeclaration error. No sane person would use anything like that.
July 22nd, 2013, 02:30 PM
[QUOTE=Jacques1]Gosh, where do you got this from? Did your cat walk over the keyboard?
No, y is not defined, because it only gets defined when you call x
can u tell me please how its happening??
July 22nd, 2013, 02:38 PM
You do understand that function y is defined inside of function x right? Without calling x, there is no y, because y doesn't get defined.
Originally Posted by sam_sam56
You first need to call x, and then you have y.
Like I said, things like this aren't done in reality, because they lead straight to debugging hell. You'd have two separate function definitions like MrFujin showed above.