Static Member Variable

in Hindi - Static Member Variable



not yet

Source Code :

RUN#include <iostream.h>
#include <conio.h>

class Test{

private:
static int i;
char name[20];

public:
void getdata(int n)
{
i=n;
}
int putdata()
{
return (i);
}
};
int Test :: i;

int main(){
    
Test t1,t2;

cout<<"Initial value of i in t1 :"<<t1.putdata()<<endl;
cout<<"Initial value of i in t2 :"<<t2.putdata()<<endl;

t1.getdata(15);

cout<<"New value of i in t1 "<<t1.putdata()<<endl;
cout<<"New value of i in t2 "<<t2.putdata()<<endl;

return 0;
}