Guest User

loggedincpp

a guest
Sep 12th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <new>
  3. #include<string>
  4. #include<istream>
  5. #include<conio.h>
  6. using namespace std;
  7. class loggedin{
  8. static int n;
  9. string user;
  10. string password;
  11. public:
  12. void setuser(string uref, string pref){
  13. user = uref;
  14. password = pref;
  15. loggedin::n++;
  16. }
  17. void getuser()
  18. {
  19. cout << "You are the " << loggedin::n << "th user" << endl;
  20. }
  21. void printdetails()
  22. {
  23. cout << "Username: " << user << endl;
  24. cout << "Password: " << password;
  25. }
  26. };
  27. int loggedin::n = 0;
  28. void main()
  29. {
  30. loggedin* lgn;
  31. char choice;
  32. int n = 0;
  33. string username,password;
  34. do
  35. {
  36. lgn = new loggedin[n];
  37. cout << "----Enter Login Details----" << endl;
  38. cout << "Enter Username: ";
  39. cin >> username;
  40. cout << "Enter Password: ";
  41. cin >> password;
  42. lgn[n].setuser(username,password);
  43. lgn[n].getuser();
  44. cout << "Do you want to enter more login details(Y/N)? ";
  45. cin >> choice;
  46. n++;
  47. }while(choice=='Y' || choice=='y');
  48. lgn[1].printdetails();
  49. getch();
  50. }
Add Comment
Please, Sign In to add comment