Search This Blog

Friday, 21 August 2020

Atic data member

 #include<iostream>

#include<conio.h>

using namespace std;

class test

{

int no;

static:

void getval(void);

static dispcount(void);

};

void test::getval(int x)

{

no=x;

cout<<"Number="<<no;

count++;

}

static void test::dispcount(void)

{

cout<<"counter="<<count;

}

int test::count;

int main()

{

test t1,t2,t3;

t1.dispcount();

t2.dispcount();

t3.dispcount();

t2.getval(100);

t2.getval(200);

t3.getval(300);

   t1.dispcount();

   t2.dispcount();

   t3.dispcount();

   getch();

   return 0;

   

}


No comments:

Post a Comment

Search This Blog

Contact Form

Name

Email *

Message *

Popular Posts