There seems to be some problem with my class

This is my.cpp file
#include <iostream>
#include "admin.h"
#include <process.h> //for exit()
#include "stdafx.h"
#include <string> //header file for string
using namespace std;

Admin::admin()
{
strcpy(username, "jam");
strcpy(password, "jam1");
};

bool Admin::check_username(string username1) //check user name
{ if (username1==username)
return true;
else return false;
}
////////////////////////////////////////////////////////////////////////////////////////
bool Admin::check_password(string password1) //check password
{ if(password==password1)
return true;
else return false;
}


void main()
{
string username1;
string password1;
bool check;


Admin administration();
while(exit()==false); //this will check the user want to continue or exit
exit(1);

do{ check=true;
system("cls"); /////clear the output //////
fflush(stdin); /////clear the input, so that can key in new input/////
//system("color 0f"); //// change color to black background and white font
cout<<"\n\n\t\t\t WELCOME TO LOGIN Menu\n";
cout<<"\n\t\t Enter the user name : ";
cin>>username1;
cout<<"\t\t Enter the password : ";
cin>>password1;
//admin --only has one admin
if(administration.check_username(username1))
if(administration.check_password(password1))
admin_menu();
////human resource
//for( int i =0;i<=hrp_no;i++)
// if(hrp_record[i].check_user_name(user_name))
// if(hrp_record[i].check_password(temp_pass))
// hr_personnel_menu();
////staff
//for( i =0;i<=staff_no;i++)
// {if(staff_record[i].check_user_name(user_name))
// if(staff_record[i].check_password(temp_pass))
// {staff_record[i].showdata();cout<<"\n\t\t";system("pause");check=false;}
}


}

bool exit() //exit menu
{ char a;
system("cls"); /////clear the output //////
fflush(stdin); /////clear the input, so that can key in new input/////
std :: cout<<"\n\t\tDo you want to exit? Y/N\n\t\t" std :: endl;
std ::cin>>a;
while(!(a=='Y' || a=='y' |a=='n' || a=='N' || a=='yes' || a=='Yes'|| a=='No'|| a=='no'))
{ cout<<"\n\t\tInvalid input. Please re-type!\n\t\t";system("pause");
system("cls"); /////clear the output //////
fflush(stdin); /////clear the input, so that can key in new input/////
//cout<<endl<<"\n\t\tAre you want to exit? Y/N\n\t\t";
//cin>>e;
std :: cout<<"\n\t\tDo you want to exit? Y/N\n\t\t" std :: endl;
std ::cin>>a;
//cin>>e;
}
if(a=='Y' ||a=='y' ||a=='Yes' ||a=='yes')
return true;
else
return false;

}

void admin_menu
{
std ::cout<<"succesfully" <<std :: endl;
}


this is my .h file
#include <string> //header file for string
using namespace std;


class Admin //administrator class
{
private:
char username[10];
char password[10];


public :
Admin(); //default constructor
bool check_username(string);
bool check_password(string);
};
 
if (username1==username)


For C Strings you need to use strcmp or strncmp.

Tim S.
what do you mean? sorry I couldn't get it.
@inception13

He means that all your doing is comparing the address of the arrays. You see lets say I have an array:

int array[5]

So now I have 5 "slots" where I can put integers. so If later in my code i put

1
2
3
4
if (array[4] == 5)
{
//...
}


I "asking" if my 5th slot equals 5 if it does then it will return true and my if statement will execute. however if I have another array int array2[5] and I want to compare the enitre array like this:
1
2
array == array2 /*returns false because array names are just pointers, and two arrays
can't exist at the same point in memory */            
Topic archived. No new replies allowed.