#include < iostream > #include < iomanip > using namespace std; class Family{ private: string name[10] ; string relation[10]; int salary[10]; public : static int count; static double Total; void getdetails(); void display (); friend void getTotal(Family item); }; int Family :: count=0; double Family :: Total=0; void Family :: getdetails(){ cout << "Enter Name: "; cin >> name[count]; cout << "\n"; cout << "Enter relation: "; cin >> relation[count]; cout << "\n"; cout << "Enter salary: "; cin >> salary[count]; cout << "\n"; count++; } inline void Family :: display (){ for (int i = 0; i < count; i++) { cout << " Name: " << name[i]<< endl; cout << " relation: " << relation[i]<< endl; cout << " salary: " << salary[i]<< endl; } } void getTotal(Family item) { int tot=0; for (int i = 0; i < Family:: count; i++) { tot=tot+item.salary[i]; } cout << "Enter Total cost: " << tot<< endl; } int main() { Family item; int numItems = 0; //number of items cout << "Enter TOtal number Family memders : "; cin >> numItems; cout << "\n"; for (int i = 0; i < numItems; ++i) { item.getdetails(); } item.display (); getTotal(item); return 0; }