Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<fstream>
- #include<vector>
- using namespace std;
- class User
- {
- string username;
- string password;
- public:
- void Register()
- {
- ofstream File("MyFile.txt");
- File.open("MyFile.txt");
- cout << "Enter the Username" << endl;
- cin >> username;
- File << username << endl;
- cout << "Enter the Password" << endl;
- cin >> password;
- File << password << endl;
- }
- void LogIn(string EnteredUser, string EnteredPassword)
- {
- cout << "Enter your Registered UserName " << endl;
- cin >> EnteredUser;
- cout << "Enter your Password " << endl;
- cin >> EnteredPassword;
- ifstream CheckAcc;
- CheckAcc.open("MyFile.txt");
- CheckAcc >> username;
- cout << "Username from the database\t" << username << endl;
- CheckAcc >> password;
- cout << "Password from the database\t" << password << endl;
- if (EnteredUser == username && EnteredPassword == password) {
- cout << "Log in is Succsesfull " << endl;
- cout << "Do you want to remove all your info ? " << endl;
- cout << "1 / 0 " << endl;
- bool choose;
- cin >> choose;
- if (choose) {
- cout << "Are you Sure ? " << endl;
- cout << "1 / 0 " << endl;
- bool SureChoose;
- cin >> SureChoose;
- if (SureChoose)
- DeleteInfo();
- }
- else LogIn(username, password);
- }
- else
- cout << "Either username or password was entered incorrectly" << endl;
- }
- void DeleteInfo() {
- ofstream DelInfo;
- DelInfo.open("MyFile.txt");
- DelInfo.clear();
- DelInfo.close();
- cout << "All of your info was removed from file ! " << endl;
- }
- };
- class User1 : public User
- {
- };
- class User2 : public User
- {
- };
- int main()
- {
- User1 user1;
- User2 user2;
- user1.Register();
- user2.Register();
- user1.LogIn("s", "b");
- user2.LogIn("a", "b");
- cin.get();
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement