Storage Classes in C++
Master C++ with Real-time Projects and Kickstart Your Career Start Now!!
Program 1
/*
Storage classes
auto
static
register
extern
-------------------------------------------
static
Memory type: RAM
default value:0
scope: local
*/
#include<iostream>
using namespace std;
void display();
int a=100;
int main()
{
int a=500;
system("cls");
cout<<a<<endl; //500
cout<<::a; //100
return 0;
}
// extern int a=10; //20
// int main()
// {
// system("cls");
// cout<<a<<endl; //10
// a=a+10;
// display();
// return 0;
// }
// void display()
// {
// cout<<a; //20
// }
// void display();
// int main()
// {
// static int a;
// system("cls");
// display();
// display();
// display();
// return 0;
// }
// void display()
// {
// static int a; //2
// cout<<a<<endl; //0 1 2
// ++a; // 2
// }If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

