146. Example of static object?

#include<iostream.h> #include<conio.h> class demo { private:                 int i; public:                 void increment()                                 {                                 i++;                                 }                 void display()                                 {                                 cout<<"\n I = "<<i<<endl;                                 } }; void main() {                 static demo d;                 clrscr();                 d.increment();                 d.display();                 getch(); }


145. Write a program to demonstrate static members using static member function?

A. #include<iostream.h> #include<conio.h> class demo { private:                 static int i; public:                 static void increment()                                 {                                 i++;                                 }                 static void display()                                 {                                 cout<<"\n I = "<<i<<endl;                                 } }; int demo::i=7; void main()         //By Using Class {                 clrscr();                 demo::increment();                 demo::display();                 getch(); } /*void main()   ... Continue Reading →

144. Write a program to differentiate the behavior between static and non-static member variable?

#include<iostream.h> #include<conio.h> class demo { private:                 static int i;                 int j; public:                 void read()                                 {                                 ++i;                                 cout<<"Enter The Value for J : ";                                 cin>>j;                                 }                 void display()                                 {                                 cout<<"The Value of I = "<<i<<"\tJ = "<<j<<endl;                                 cout<<"The Address of I = "<<(unsigned)&i<<"\tJ... Continue Reading →

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: