Friday, August 26, 2022

STATIC FUNCATION

 #include<iostream>

using namespace std;


class test

{

public:

     int a;

     static int count;

     test()

     {

   a=10;

           count++;

     }

     static int getcount()

     {

   return count;

     }

};

int test::count=0;

int main()

{

test t1,t2;

cout<<test::getcount()<<endl;

cout<<t1.getcount()<<endl;

}

No comments:

Post a Comment

CONSTRUCTURE IN PARENT CLASS

class Parent {     public Parent()     {         System.out.println("Parent Constrcutor");     }              } class Child extend...