Static Member Functions in Classes




This video tutorial explains the static member functions in classes.

You are gonna learn what are static member function, how to use static members in static member functions inside a class, how to declare static member functionss in classes and use them in detail with example.

source code for this tutorial

#include <iostream>

using namespace std;

class Human{
public:
    static int human_count;

    Human(){
    human_count++;
    }

    void humanTotal(){
    cout << "There are "<<human_count<<" peoples are in this program" <<endl;
    }

    static void humanCount(){
     cout << "There are "<<human_count<<" peoples are in this program " <<endl;
    }

};

int Human::human_count = 0;
int main()
{
cout << Human::human_count<<endl;

Human anil;
Human anjali;
Human rashith;
Human sandeep;
Human ::humanCount();
cout << Human::human_count<<endl;

    return 0;
}


 
Back To Top