This is a C++ question with multiple parts. Please read carefully. In this assig
ID: 650519 • Letter: T
Question
This is a C++ question with multiple parts. Please read carefully.
In this assignment, you will write a struct plus 2 simple classes and then write a program that uses all of them. The 1st class is a Date class. The 2nd is a Patient class. The program will keep track of patients at a walk-in clinic. For each patient, the clinic keeps a record of all procedures done. This is a good candidate for a class, but to simplify the assignment, you need to make a procedure into a struct. We will assume that the clinic has assigned all care providers (doctors, nurses, lab technicians) with IDs and each procedure (
Explanation / Answer
//
Definition of Structure:
Structures are a way of storing many different values in variables of potentially different types under the same name. This makes it a more modular program, which is easier to modify because its design makes things more compact. Structs are generally useful whenever a lot of data needs to be grouped together--for instance, they can be used to hold records from a database or to store information about contacts in an address book. In the contacts example, a struct could be used that would hold all of the information about a single contact--name, address, phone number, and so forth.
Structure cannot be used to store procedures ...
Check the program.. to proceed
#include<iostream>
#include<string>
#include<fstream>
#include<stdio.h>
using namespace std;
class Date
{
int date;
public:
Date(int d){date=d;}
int getDate()
{
return date;
}
void setDate(int d)
{
date=d;
}
}
class Patient
{
int id;
string firstname,lastname,doctordetails;
int d1,doc;
Patient(int id,string firstname,string lastname,int docid,Date d)
{
Patient.firstname=firstname;
Patient.lastname=lastname;
doc=doc;
d1=d.getDate();
}
string getFirstName()
{
return firstname;
}
void setFirstName(string s)
{
firstname=s;
}
string getLastName()
{
return lastname;
}
void setLastName(string s)
{
lastname=s;
}
}
int main()
{
int x;
char * buffer;
long size;
ifstream file ("CurrentPatients.dat", ios::in|ios::binary|ios::ate);
size = file.tellg();
file.seekg (0, ios::beg);
buffer = new char [size];
file.read (buffer, size);
file.close();
cout << "the complete file is in a buffer";
delete[] buffer;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.