Class Acount

Published on January 2017 | Categories: Documents | Downloads: 41 | Comments: 0 | Views: 242
of 2
Download PDF   Embed   Report

Comments

Content

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

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close