MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

Data Type C++

C++ Storage Classes
Previous Home Next

Storage classes define the scope and lifetime of the variable and function within a C program.

Types of Storage Classes in C++

  1. Auto
  2. Register
  3. Static
  4. Extern
  1. Auto Storage Class:- This is the default storage class for local variables.
  2. For example:
     {
    int num;
    auto int month; 
     }
    
  3. Register Storage Class:-This is used to define the local variable that should be stored in register instead of RAM.
  4. For example.
     {
     register int miles; 
     }
    
  5. Static Storage Class:-This is the default storage class for global variables.
  6. For example:
    {
    int num;
    static int count;
    main()
    cout<<count;
    }
    

     

  7. Extern Storage Class:- Extern is use to give a reference of global variable that is visible to all the program files.
  8. For example:
    //File 1: main.cpp
    #include <iostream>
    #include <conio.h>
    int count ;
    extern void write_extern();
    main()
    {
    count = 5;
    write_extern();
    } 
    
    //File 2: write.cpp
    #include <iostream>
    #include <conio.h>
    extern int count;
    void write_extern(void)
    {
    std::cout << "Count is " << count << std::endl;
    } 
    

    Note:-Here extern keyword is being used to declare count in another file.

Previous Home Next