static variable

Total Post:113

Points:791

C#  Python 
 442  View(s)
Ratings:
Rate this:

What does static variables mean ?

  1. Re: static variable

    Static variables :

    access qualifier are known as static var. variable as static inside a function is declared than, the scope is less to the function, but it will exists for the life time of the program. Values will be persisted between successive calls to a function.

     #include<stdio.h> 
    int fun() 
    {  static int count = 0;  count++;  return count; 
    }  int main()  {  printf("%d ", fun());  printf("%d ", fun());  return 0;  } 

    in python it does not require for static keywords. inside this classs the method having instant var.

    class CSStudent: 
        stream = 'cse' // Class Variable     def __init__(self,name,roll):         self.name = name // Instance Variable         self.roll = roll // Objects of CSStudent class a = CSStudent('Prakash', 1) b = CSStudent('Nidhi', 2) print(a.stream) print(b.stream) print(a.name) print(b.name) print(a.roll) print(b.roll) print(CSStudent.stream)

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.