Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

EX.NO:1.

3 CLASS WITH STATIC MEMBER FUNCTIONS


To implement a class with Static member functions.

ALGORITHM:
1) Start the program. 2) Create the Class customer with two member functions and one non member Function static. 3) Define the member functions outside the class. 4) Create an objects c1 and c2 for already created class item. 5) Call the member functions by using dot operator. 6) Stop the program.

SOURCE CODE:

#include<iostream.h> #include<conio.h> class customer { private: static int count; int accountno; public: void setaccountno(void); void displayaccountno(void); void static displaycount(void); }; int customer::count; void customer::setaccountno(void) {count++; accountno=count; }void customer::displayaccountno(void) {cout<< "The Account Number Is:"<< accountno<< endl; }void customer::displaycount(void)

{cout<< "The Total Numer Of Accounts Are:"<< count<< endl; }void main() {customer c1,c2; clrscr(); c1.setaccountno(); c2.setaccountno(); c1.displayaccountno(); c2.displayaccountno(); c1.displaycount(); getch();
}Output: THE ACCOUNT NUMBER IS: 1 THE ACCOUNT NUMBER IS: 2 THE TOTAL NUMER OF ACCOUNTS ARE: 2

You might also like