Professional Documents
Culture Documents
Question: - : Explain The Difference Between Static Class Data and Automatic Class Data With The Help of A Program
Question: - : Explain The Difference Between Static Class Data and Automatic Class Data With The Help of A Program
Question: - : Explain The Difference Between Static Class Data and Automatic Class Data With The Help of A Program
Department:- Telecommunication
Section:- “B”
Quiz No:- 01
Question: - Explain the difference between static class data and automatic class
data with the help of a program
Answer:-
int MyClass::resource;
int main()
{
MyClass ob1, ob2;
if(ob1.get_resource())
cout <<”Resources with ob1”;
if(!ob2.get_resource())
cout <<”Resources denied to ob2”;
ob1.free_resource();
return 0;
}
The register storage class is used to define local variables that should be stored in a register
instead of RAM. This means that the variable has a maximum size equal to the register size
(usually one word) and can't have the unary '&' operator applied to it (as it does not have a
memory location)
#include <iostream>
// Function declaration
void func(void);
main() {
while(count--) {
func();
}
return 0;
}
// Function definition
void func( void ) {
static int i = 5; // local static variable
i++;
std::cout << "i is " << i ;
std::cout << " and count is " << count << std::endl;
}
THE END