Program to illustrate static members in class

#include <iostream.h>
#include<conio.h>
class test
{
    int code;
    static int count;    // static member variable
    public :
    void setcode (void)
    {
        code = ++count;
    }
    void showcode (void)
    {
        cout << "Object number : " << code << "\n";
    }
    static void showcount(void)        // static number function
    {
        cout << "Count : "<<count<<"\n";
    }
};
    int test :: count;
    int main()
    {
        test t1, t2;
        clrscr();
        t1.setcode();
        t2.setcode();

        test :: showcount();    // accessing static function

        test t3;
        t3.setcode ( );

        test :: showcount();

        t1.showcode();
        t2.showcode();
        t3.showcode();
        getch();
    }

13 comments:

  1. telefonsex
    Everything is very open with a clear explanation of
    the issues. It was really informative. Your site is useful.
    Thanks for sharing! telefon sex

    My blog post blog

    ReplyDelete
  2. Ahaa, its good discussion concerning this piece
    of writing at this place at this weblog, I have read all that, so at this time me also commenting here.



    Look into my site :: Criminal Case Cheats

    ReplyDelete
  3. Hello you have done so nice work. Well and responsive blog thank you dear admin well designed Keep it up thank you
    Regards:
    windows 10 loader

    ReplyDelete

  4. http://codeprecisely.blogspot.in//2011/11/program-to-illustrate-static-members-in.html

    ReplyDelete