Subscribe Us

Responsive Advertisement

Advertisement

Static Class Member C++ | | OOP

 


Static Class Member C++ | |  OOP



#include<bits/stdc++.h>

using namespace std;

class item

{

    static int cnt;

    int x;

public :

    void get(int y)

    {

        x=y;

        cnt++;

    }

    void show()

    {

        cout<<cnt<<endl;

    }

};

int item::cnt;

int main()

{

    item a,b,c;

    a.get(1);

    b.get(1);

    b.show();

    c.get(1);

    a.show();


    return 0;

}


Post a Comment

0 Comments