Wednesday, 11 January 2012

Program To Find Area of Circle Using Static Member Function In C++

#include<iostream.h>
#include<conio.h>

class test
{
                                    private:           //static Data Member   
static int a;
                              static float pi;       // Static Data Member
public:
                          void static display()        // Static Member 
Function
{
cout<<"\n Main Class Value is="<<pi*a*a;
}
} ;
float test :: pi = 3.14;   // Static Data Member Initialization
int test :: a = 5;   //Static Data Member Initialization

main()
{
clrscr();
test t1;
t1.display();
getch();
}

No comments:

Post a Comment