#include <iostream>
#include <string>
using namespace std;
class Customer;
class City;
class Customer
{
protected:
int number;
string zipcode;
public:
Customer(int, string);
friend void displayCust(const Customer&, const City&);
};
Customer::Customer(int num = 0, string zcode = "")
{
number = num;
zipcode = zcode;
}
class City: public Customer
{
public:
string cityname;
string citystate;
string zipcode2;
public:
City(string, string, string);
friend void displayCust(const Customer&, const City&);
};
City::City(string cname = "", string cstate = "", string zcode2 = "")
{
cityname = cname;
citystate = cstate;
zipcode2 = zcode2;
}
void displayCust(const Customer& cus, const City& cit)
{
cout << "the number of customer: ";
cus.number;
cout << "\nThe customers city: ";
cit.cityname;
cout << "\nThe customers state is: ";
cit.citystate;
cout << "\nThe customers zipcode is: ";
cit.zipcode2;
}
void main()
{
Customer aCust(1572, "60013");
City aTown("Cary", "Illinois", "60013");
displayCust(aCust, aTown);
}
im so confused right now, i dont understand why this code wont work NOW, it worked before and i have not changed it at all, id like to understand why it doesnt work, i matched the public void function up with the friend functions in both the base class and the derived class, it will even output the text but not the selected data that is called in the public void function. i need help badly. thanks

New Topic/Question
Reply



MultiQuote





|