Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <new>
- #include<string>
- #include<istream>
- #include<conio.h>
- using namespace std;
- class loggedin{
- static int n;
- string user;
- string password;
- public:
- void setuser(string uref, string pref){
- user = uref;
- password = pref;
- loggedin::n++;
- }
- void getuser()
- {
- cout << "You are the " << loggedin::n << "th user" << endl;
- }
- void printdetails()
- {
- cout << "Username: " << user << endl;
- cout << "Password: " << password;
- }
- };
- int loggedin::n = 0;
- void main()
- {
- loggedin* lgn;
- char choice;
- int n = 0;
- string username,password;
- do
- {
- lgn = new loggedin[n];
- cout << "----Enter Login Details----" << endl;
- cout << "Enter Username: ";
- cin >> username;
- cout << "Enter Password: ";
- cin >> password;
- lgn[n].setuser(username,password);
- lgn[n].getuser();
- cout << "Do you want to enter more login details(Y/N)? ";
- cin >> choice;
- n++;
- }while(choice=='Y' || choice=='y');
- lgn[1].printdetails();
- getch();
- }
Add Comment
Please, Sign In to add comment