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)
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
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.
in python it does not require for static keywords. inside this classs the method having instant var.