I have just finished the sololearn C++ course and wanted to create a basic login program in the vein of a basic operating system.
#include "ubuntu_login"
#include <iostream>
#include <string>
using namespace std;
Ubuntu_Login::Ubuntu_Login()
{
cout << "\t Welcome to Ubuntu!\n" << endl;
}
void Ubuntu_Login::usr_login()
{
cout << "Please enter a username" << endl;
getline(cin,username);
cout << "Please enter a password" << endl;
getline(cin,password);
while(username_input != username || password_input != password)
{
cout << "\n|Ubuntu Login|" << endl;
cout << "Please enter your username" << endl;
getline(cin, username_input);
cout << "Please enter your password" << endl;
getline(cin, password_input);
if(username_input != username || password_input != password)
{
cout << "Incorrect username or password" << endl;
}
}
}
#include "ubuntu_login.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
Ubuntu_Login UO;
UO.usr_login();
}
Header file:
#ifndef UBUNTU_LOGIN_H
#define UBUNTU_LOGIN_H
#include <string>
using namespace std;
class Ubuntu_Login
{
public:
Ubuntu_Login();
void usr_login();
private:
string username;
string password;
string username_input;
string password_input;
};
#endif // UBUNTU_LOGIN_H
Any help on improving my code by getting rid of useless code or replacing it with better code would be greatly appreciated.