Consider the following class declaration class patientrecord
     Consider the following class declaration: class patient_record {public: int age; string name; double service_charge;}; implement the void function \"print_to_file\" which prints all the patient records stored in DB to a file called \"our_patients.txt\". Open and close the ofstream inside the function. Consider the following prototype to help you write (code) this function: void print_to_file(patient_record *DB, const int & count) 
  
  Solution
Here is the code for you:
#include <iostream>
 #include <fstream>
 using namespace std;
 class patient_record
 {
 public:
 int age;
 string name;
 double service_charge;
 };
 void print_to_file(patient_record *DB, const int &count)
 {
 ofstream fout;
 fout.open(\"our_patients.txt\");
 for(int i = 0; i < count; i++)
 {
 fout<<(DB+i)->age<<\" \"<<(DB+i)->name<<\" \"<<(DB+i)->service_charge<<endl;
 }
 }

