What is scope of a variable? (LOLZ)

Answers were Sorted based on User's Feedback

What is scope of a variable? (LOLZ)..

Answer / aboelella

Variable scope is the places in code where this variable can
be accessed

Varaible can be defined to be global (visible in the program
include scope)

Variable can be local if defined in the scope of parantesis
(inside function or in compound statement)

In classes variables scope depends on the way it is defined
(privat, public or protected)

Is This Answer Correct ?    21 Yes 0 No

What is scope of a variable? (LOLZ)..

Answer / lovly

One of the really big pluses with GOSUB/RETURN is that you
can share variables that are neither global nor restricted
to one piece of code.

With or without that functionality, how about a way to
share variables (with memory of course) between only
certain subs/functions? Something like:
(per function/sub)

"STATIC SHARED as integer namespace_name.variable_name =
0" -OR-
"STATIC SHARED namespace_name.variable_name as integer"

Usage would just be: "variable_name" -- no "." or namespace

I think that would be a great addition to FB. Thoughts

Is This Answer Correct ?    2 Yes 5 No

Post New Answer

More C++ General Interview Questions

write a C++ programming using for loop: * * * * * * * * * *

4 Answers   TCS,

if there is binary tree which one is the easiest way to delete all child node?

1 Answers   Persistent,

How to avoid changing constant values?

2 Answers   Symphony,

Give a very good method to count the number of ones in a "n" (e.g. 32) bit number.

3 Answers  

Memory is not a constraint. In a single iteration(NOTE: you can't go back), how will you find out the 10th last node/item in a linked list.

16 Answers   Nagarro, Goldman Sachs, BNB, FDS,

Explain "passing by value", "passing by pointer" and "passing by reference" ?

5 Answers  

How do you link a C++ program to C functions?

3 Answers  

how to swap two strings without using any third variable ?

11 Answers  

when can we use virtual destructor?

7 Answers   HP, HCL, Virage Logic,

Difference between delete and delete[]?

5 Answers   TCS, Virtusa, Infosys,

Under what conditions is multiple inheritance not recommended?

1 Answers  

diff between pointer and reference in c++?

1 Answers