Answer to Question #38717 in C++ for Gaurav shukla

Question #38717
when we declare function1 in function2 then other function(other than function2) are not allowed to call function1. but when we overload function1 then we can call it anywhere (in any function) why?
1
Expert's answer
2014-02-06T12:14:29-0500
Dear Gaurav,
There is a concept of "scope" in the programming.
When you declare function2 inside of function1 like this
function1 {
function2 {

}
}
it can be accessed from function1 only as it was declared in its scope.
If you want to use function2 in other functions you will have to declare it in the global scope, like this:
function1 {
}
function2 {
}
I this case function1 and function2 can be accessed from any other function.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS