explain about scope and storage class in oops
Answer / Jasvant Singh
In Object-Oriented Programming (OOP), Scope and Storage Class are essential concepts that determine the visibility, accessibility, and lifespan of variables and objects within a program. Here's an explanation of both:
1. Scope:
- Local Variable: Declared within a function or block, visible only within that scope.
- Global Variable: Declared outside any functions or blocks, accessible from anywhere in the program.
- Static Variable: Declared with the `static` keyword, maintained between function calls but still within the same scope.
2. Storage Class:
- Automatic (or auto): Created when a function or block is entered and destroyed once the function or block exits. Example: local variables in C++.
- Static: Allocated and deallocated only once during the entire execution of the program, maintaining its value between function calls. Example: static variables in C++.
- Extern: Declared outside any functions or blocks with no initial value. Used to define global variables that are shared across multiple source files.
- Register: Optimization directive to store a variable in a processor register instead of memory, which can lead to faster access times but limited space. Not supported by all compilers.
| Is This Answer Correct ? | 0 Yes | 0 No |
which of the following is not a storage class specifier in c?
what is dbms and rdbms??
Explain a situation in which you handled a customer?s questions or problems?
what is the formula/ ratio for hollow block? considering to a 40 kgs of portland cement.
what is static identifier in c language?
An inversion is an array of numbers is any pair (i,j) such that i<j and A[i]>A[j]. What is the average number of inversions in an array of n distinct numbers? plz GIVE ME SOLUTION
sir i have 4 year gap in engineering. i would complete my degree b.tech it in 2014. it will be may be in 2nd class.my hsc is also with 2nd class. i am week in programming. Then if i want highest package upto 5-6 lacs then what should i prepare myself as a good engineer to get this package???
i need to know abt renault nissan company and the rounds and type of questions asked by today
explain different access specifiers in class
compair and contrast procedrual and object oriented programming language
what is the pri request of binary search
Which one is more efficient in terms of required memory space call-by-value or call-by-referance?
Civil Engineering (5086)
Mechanical Engineering (4453)
Electrical Engineering (16638)
Electronics Communications (3918)
Chemical Engineering (1095)
Aeronautical Engineering (239)
Bio Engineering (96)
Metallurgy (361)
Industrial Engineering (259)
Instrumentation (3014)
Automobile Engineering (332)
Mechatronics Engineering (97)
Marine Engineering (124)
Power Plant Engineering (172)
Textile Engineering (575)
Production Engineering (25)
Satellite Systems Engineering (106)
Engineering AllOther (1379)