0
What is scope of data structure ?
is this compulsory to learn it ?
1 ответ
+ 12
Definitely, it's important! Scope refers to where you can use a data structure, variable, or method. Some people describe it as it's "lifespan". It depends on where and how you define it.
For example, let's say you write a for loop:
for (int i = 0; i < 10; i++)
{
//Your code
}
You're only able to use the i counter in the for loop (inside the {}). i's scope only last for the duration of the for.
A variable made inside a method only last inside that method. Methods only last inside the class they're in. Global items last for the entire program.