adspace
Answer Posted / 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 |
Post New Answer View All Answers
hi, i applied for AIRPORTS AUTHORITY OF INDIA for the post of AIR TRAFFIC CONTROLLER(ATC)..so plz send me the sample questions to my id...88arun@gmail.com
can any one send me the configuration of cisco 1841 router????/
Can anyone send me iocl written test paper fro computer engineers
What is the instruction to load the register B?
HELLO ALL OF U.I HAVE QUALIFIED IN SBI CLERICAL WRITTEN EXAMINATION AND MY INTERVIEW IS ON 20TH OF THIS MONTH.IAM SOTWARE BACKGROUNDED CANIDIATE SO CAN ANY ANYBODY WHOSE INTERVIEW IS OVER CAN TELL ME THAT WHAT QUESTIONS THEY ASKED RELATING TO COMPUTER SCIENCE.
need tcs questn papers from 2007 to 2009 plzzzmail to 9015.rama@gmail.com its urgent
What would be your first invention?
please send me latest Aptitude Test paper
Write a function that responds to a click anywhere on the page by displaying an alert dialog. Display the event name if the user held Shift during the mouse click. Display the element name that triggered the event if the user held Ctrl during the mouse click.
i need NIC written test paper or give me any idea about written exam.Plz send me at smileever8@gmail.com
what is the different between view and materialized view in oracle DBA?
Please send me the ongc old question papers
pls send me the e-book for verbal and non verbal reasoning of R S aggarwall
sir, please send me the last three years exam papers conducted by CPCL- RECRUITMENT EXAM FOR Recruitment of Engineer ELECTRICAL ENGINEERING. A Soon as possible. i would be greatfull to u
why c is called middle level langauge?