How do I use my void function as a class?

I am trying to understand classes. I'm supposed to use my login system as a class. I don't know what the difference would be between using a class an just invoking a function.

Try your best not to be snobby.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
using namespace std;
class LoginSystem {

string** labs;

public:

   void login();

  };
void login()
{
    string newName;
    string newPassword;
    string loginName;
    string loginPassword;
    
    
        cout << "Please enter new user name: ";
        cin >> newName;
        cout << "Please enter new user password: ";
        cin >> newPassword;
        cout << "Enter login name: ";
        cin >> loginName;
        cout << "Enter password: ";
        cin >> loginPassword;
        if (loginName == newName && loginPassword == newPassword) 
        {
            cout << "Welcome " << loginName << endl;
            
        }
        else
        {
            cout << "Invalid login attempt. Please try again.\n" << '\n';
            
        }
        
    }

int main ()
{
   


    
}

  
Last edited on
Topic archived. No new replies allowed.