how do i include classes in my code. my lab notes say i need to include classes.

#include <iostream>
#include <string>
#include <stdlib.h>
#include <cstdlib>
#include <fstream>

using namespace std;


void login();
void Members();
void PassChange();

string inuser;
string inpass;
string user;
string pass;
string tempass;
string data;
string Menu;
string iMenu;
int num =0;
int limit;
int i=0;
int sel =0;



int main()
{
    cout <<"\nWELCOME to my Web System\n";
    while(num==0)
    {
        cout<<"\nMenu :\n(1)Login\n(2)Change Password\n(4)Exit\n";
        cin >> Menu;
     if(Menu == "1")
      {
          login();
          
      }
     else if(Menu=="2")
      {
          PassChange();
      }
     else if(Menu == "4")
      {
           cout<<"\nGoodBye\n";
           getchar();
           return (EXIT_SUCCESS);
           }

    }

}

void login()
{

    

    
     ifstream Passfile("/home/user/password", ios::in);
     Passfile>>inpass;
     ifstream Userfile("/home/user/username", ios::in);
     Userfile>>inuser;
     //system("cls");
     for (i=0; i<3; i++)
     {
     
     cout<<"USERNAME: ";
     cin>>user;  
     cout<<"PASSWORD: ";
     cin>>pass;
     Userfile.close();
     Passfile.close();

     
     if(user==inuser&&pass==inpass)
     {
     
     getchar();
     Members();
     }
     else if (user!=inuser && pass!=inpass)

         cout<<"\nWrong Username / Password\n";
     else
         
     {
         cout<<"\nOver\n";break;
     }
}
     
     //for
     //cout<<"\nWrong Username / Password\n";

     //else
         //cout<<"\nSystem locked up\n";
         
     
     
}

void Members()
{
     cout<<"\nWelcome\n";
     while(sel==0)
    {
        cout<<"\nInteractive Menu :\n";
        cout<<"a) Add New Sales Transaction\n";
        cin >> iMenu;
     if(iMenu == "a")
      {
         //cout<<"Enter Format: [Item Description]:[Unit Price]:[Quantity Purchased]:[Date Purchased]\n";
         //cin >> data;
         //ofstream DataFile ("/home/user/data", ios::app);
         //DataFile << data<<"\n";
         //DataFile.close();
         //cout<<"Data has been stored.";
         //getchar();
         
         //Members();
      }
     //else if(iMenu=="2")
      //{
        //  PassChange();
      //}
     //else if(iMenu == "4")
      //{
        //   cout<<"\nGoodBye\n";
        //   getchar();
        //   return (EXIT_SUCCESS);
         //  }

    }



     // put members code here
     // like a while(){} loop or somethin like that
     // comment please
}

void PassChange()
{
     //system("cls");
     ifstream Userfile("/home/user/username", ios::in);
     Userfile>>inuser;
     cout<<"USERNAME: ";
     cin>>user;
     ifstream Passfile("/home/user/password", ios::in);
     Passfile>>inpass;
     cout<<"Enter your current password: ";
     cin>>tempass;
     if(user==inuser&&tempass==inpass)
     {
     cout<<"Utility to change password stored in file\n";
     cout<<"Enter your new password: ";
     cin>>user;
     ofstream Passfile("/home/user/password", ios::out);
     Passfile << user;
     Passfile.close();
     Userfile.close();
     cout<<"\nYour password has been successfully changed\n";
     getchar();
     main();
}
     else
{
    cout<<"\nWrong Username / Password,unable to change password\n";
    getchar();
    main();
}
}

Recommended Answers

All 2 Replies

A "class" is a kind of C++ object that you can define and then create. If you need to include one, I suggest you read up on what classes are, and then write one.

http://www.cplusplus.com/doc/tutorial/classes/

Do you know what a class is? Have you learned anything about object oriented programming?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.