Please Help, sitting here for hours, cannot figure it out.

I have homework due tomorrow and I have all my code written, but I have I function that I cannot seem to work. With the login class i am trying to call the username from within the customer class. The username is private. I just dont know exactly how to do it. I have literally spend about 5 hours on this same problem. I have referenced many websites with not success. Any help would be appreciated.

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
class customer
{
public:


	void setCustomerInfo();
	void getCustomerInfo();
	void read_record();

private:
	string firstName;
	string lastName;
	string age;
	string streetAddress;
	string city;
	string state;
	string zip;
	string phoneNumber;
	string userName;
	string password;
	string passwordVerify;
	


};


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
class userLogin
{
	void userLogin_Verify()
	{
		string usernameLogin;
		string passwordLogin;
		customer::userName; //a nonstatic member referecnce must be relative to a specific object

		int login();

		cout << endl << "Username: ";
		cin >> usernameLogin;
		cout << endl << "Password: ";
		cin >> passwordLogin;

		while (usernameLogin != customer::userName)//a nonstatic member referecnce must be relative to a specific object
		{
			cout << endl << "The information you have entered is incorrect!" << endl;
			cout << endl << "Username: ";
			cin >> usernameLogin;
			cout << endl << "Password: ";
			cin >> passwordLogin;
		}
	}
};
Last edited on
You need to add a getter to your customer class that returns the users name.
something like std::string getName() const { return userName; }

You are also going to need an object of the class customer.
1
2
customer a;
a.getName();
Last edited on
Topic archived. No new replies allowed.