I am struggling to enable friendship between two classes in separate header files for a banking program.
I am attempting to get the Person class to use variables from the Account class. Heres what I have so far.
ACCOUNT.h:
PERSON.h:Code:#include<iostream> #include<fstream> #include<cctype> #include<iomanip> #include <string> #include <math.h> #include <windows.h> #include <vector> #include "Person.h" using namespace std; class person; class account { int deposit; friend class person; public: void dep(int); //function to accept amount and add to balance amount void draw(int); //function to accept amount and subtract from balance amount int retdeposit() const; //function to return balance amount friend class person; };
Code:#ifndef PERSON_H #define PERSON_H #include<iostream> #include<fstream> #include<cctype> #include<iomanip> #include <string> #include <math.h> #include <windows.h> using namespace std; class person { int acno; char name[50]; char add[50]; char dob[10]; char type[30]; char tele[12]; char mort; char mortgage; double Principle; double initialPrinciple; double yearlyInterest; double initialYearlyInterest; double monthlyInterest; double initialMonthlyInterest; double monthlyPayment; double initialMonthlyPayment; int lengthInYears; float lengthInYears2; double initialLengthinYears; int lengthInMonths; int initialLengthInMonths; public: void create_account(); //function to get data from user void show_account() const; //function to show data on screen modify(); //function to add new data void report() const; //function to show data in tabular format int retacno() const; //function to return account number char rettype() const; //function to return type of account #endif // PERSON_H }; //class ends here




Reply With Quote